Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-06-04 09:27:51
Exec Total Coverage
Lines: 1790 4258 42.0%
Functions: 131 329 39.8%
Branches: 958 2730 35.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 #include "zc/zc_sys.h"
13
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 #include <math.h>
18 #include <map>
19 #include <filesystem>
20 #include <ctype.h>
21 #include <sstream>
22 #include "base/zc_alleg.h"
23 #include "gamedata.h"
24 #include "zc/zc_init.h"
25 #include "init.h"
26 #include "zc/replay.h"
27 #include "zc/cheats.h"
28 #include "zc/render.h"
29 #include "base/zc_math.h"
30 #include "base/zapp.h"
31 #include "dialog/cheatkeys.h"
32 #include "metadata/metadata.h"
33 #include "zc/zelda.h"
34 #include "tiles.h"
35 #include "base/colors.h"
36 #include "pal.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "zc/zc_sys.h"
40 #include "play_midi.h"
41 #include "jwin_a5.h"
42 #include "base/jwinfsel.h"
43 #include "base/gui.h"
44 #include "midi.h"
45 #include "subscr.h"
46 #include "zc/maps.h"
47 #include "sprite.h"
48 #include "zc/guys.h"
49 #include "zc/hero.h"
50 #include "zc/title.h"
51 #include "particles.h"
52 #include "zconsole.h"
53 #include "zc/ffscript.h"
54 #include "dialog/info.h"
55 #include "dialog/alert.h"
56 #include "zc/combos.h"
57 #include <fmt/format.h>
58
59 #ifdef __EMSCRIPTEN__
60 #include "base/emscripten_utils.h"
61 #endif
62
63 extern FFScript FFCore;
64 extern bool Playing;
65 int32_t sfx_voice[WAV_COUNT];
66 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
67 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
68
69 extern byte monochrome_console;
70
71 extern HeroClass Hero;
72 extern FFScript FFCore;
73 extern ZModule zcm;
74 extern zcmodule moduledata;
75 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
76 extern particle_list particles;
77 extern int32_t loadlast;
78 extern word passive_subscreen_doscript;
79 extern bool passive_subscreen_waitdraw;
80 extern char *sfx_string[WAV_COUNT];
81 byte use_dwm_flush;
82 byte use_save_indicator;
83 byte midi_patch_fix;
84 bool midi_paused=false;
85 int32_t paused_midi_pos = 0;
86 byte midi_suspended = 0;
87 byte callback_switchin = 0;
88 byte zc_192b163_warp_compatibility;
89 char modulepath[2048];
90 bool epilepsyFlashReduction;
91 signed char pause_in_background_menu_init = 0;
92 byte pause_in_background = 0;
93 bool is_sys_pal = false;
94 static bool load_control_called_this_frame;
95 extern PALETTE* hw_palette;
96 extern bool update_hw_pal;
97 extern const char* dmaplist(int32_t index, int32_t* list_size);
98 int32_t getnumber(const char *prompt,int32_t initialval);
99
100 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
101 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
102 //extern byte refresh_select_screen;
103 //extern movingblock mblock2; //mblock[4]?
104 //extern int32_t db;
105
106 static const char *ZC_str = "Zelda Classic";
107 extern char save_file_name[1024];
108 #if defined(ALLEGRO_WINDOWS)
109 const char *qst_dir_name = "win_qst_dir";
110 static const char *qst_module_name = "current_module";
111 #elif defined(ALLEGRO_LINUX)
112 const char *qst_dir_name = "linux_qst_dir";
113 static const char *qst_module_name = "current_module";
114 #elif defined(__APPLE__)
115 const char *qst_dir_name = "osx_qst_dir";
116 static const char *qst_module_name = "current_module";
117 #endif
118 #ifdef ALLEGRO_LINUX
119 static const char *samplepath = "samplesoundset/patches.dat";
120 #endif
121 char qst_files_path[2048];
122
123 #ifdef _MSC_VER
124 #define getcwd _getcwd
125 #endif
126
127 bool rF11();
128 bool rI();
129 bool rQ();
130 bool zc_key_pressed();
131
132 #ifdef _WIN32
133
134 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
135 extern "C"
136 {
137 typedef HRESULT(WINAPI *t_DwmFlush)();
138 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
139 }
140
141 void do_DwmFlush()
142 {
143 static HMODULE shell = LoadLibrary("dwmapi.dll");
144
145 if(!shell)
146 return;
147
148 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
149 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
150
151 BOOL enabled;
152 isEnabled(&enabled);
153
154 if(isEnabled)
155 flush();
156 }
157
158 #endif // _WIN32
159
160 82835 bool flash_reduction_enabled(bool check_qr)
161 {
162
4/4
✓ Branch 0 taken 80614 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 80158 times.
✓ Branch 3 taken 82379 times.
82835 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
163 }
164
165 // Dialogue largening
166 void large_dialog(DIALOG *d)
167 {
168 large_dialog(d, 1.5);
169 }
170
171 void large_dialog(DIALOG *d, float RESIZE_AMT)
172 {
173 if(!d[0].d1)
174 {
175 d[0].d1 = 1;
176 int32_t oldwidth = d[0].w;
177 int32_t oldheight = d[0].h;
178 int32_t oldx = d[0].x;
179 int32_t oldy = d[0].y;
180 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
181 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
182 d[0].w = int32_t(d[0].w*RESIZE_AMT);
183 d[0].h = int32_t(d[0].h*RESIZE_AMT);
184
185 for(int32_t i=1; d[i].proc !=NULL; i++)
186 {
187 // Place elements horizontally
188 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
189 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
190
191 if(d[i].proc != d_stringloader)
192 {
193 if(d[i].proc==d_bitmap_proc)
194 {
195 d[i].w *= 2;
196 }
197 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
198 }
199
200 // Place elements vertically
201 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
202 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
203
204 // Vertically resize elements
205 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
206 {
207 d[i].h = int32_t((double)d[i].h*1.5);
208 }
209 else if(d[i].proc == jwin_droplist_proc)
210 {
211 d[i].y += int32_t((double)d[i].h*0.25);
212 d[i].h = int32_t((double)d[i].h*1.25);
213 }
214 else if(d[i].proc==d_bitmap_proc)
215 {
216 d[i].h *= 2;
217 }
218 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
219
220 // Fix frames
221 if(d[i].proc == jwin_frame_proc)
222 {
223 d[i].x++;
224 d[i].y++;
225 d[i].w-=4;
226 d[i].h-=4;
227 }
228 }
229 }
230
231 for(int32_t i=1; d[i].proc!=NULL; i++)
232 {
233 if(d[i].proc==jwin_slider_proc)
234 continue;
235
236 // Bigger font
237 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
238
239 if(!d[i].dp2 && bigfontproc)
240 {
241 d[i].dp2 = get_zc_font(font_lfont_l);
242 }
243 else if(!bigfontproc)
244 {
245 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
246 }
247
248 // Make checkboxes work
249 if(d[i].proc == jwin_check_proc)
250 d[i].proc = jwin_checkfont_proc;
251 else if(d[i].proc == jwin_radio_proc)
252 d[i].proc = jwin_radiofont_proc;
253 }
254
255 jwin_center_dialog(d);
256 }
257
258
259 /**********************************/
260 /******** System functions ********/
261 /**********************************/
262
263 static char cfg_sect[] = "zeldadx"; //We need to rename this.
264 static char ctrl_sect[] = "Controls";
265 static char sfx_sect[] = "Volume";
266
267 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
268 {
269 return D_O_K;
270 }
271
272 bool is_reserved_key(int c)
273 {
274 switch(c)
275 {
276 case KEY_ESC:
277 return true;
278 }
279 return false;
280 }
281 bool is_reserved_keycombo(int c, int modflag)
282 {
283 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
284 return true;
285 return false;
286 }
287 bool checkcheat(Cheat cheat)
288 {
289 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
290 return true; //Main key pressed
291 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
292 return true; //Alt key pressed
293 return false;
294 }
295 34 void load_default_cheatkeys()
296 {
297 34 memset(cheatkeys, 0, sizeof(cheatkeys));
298 34 cheatkeys[Cheat::Life][0] = KEY_H;
299 34 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
300 34 cheatkeys[Cheat::Magic][0] = KEY_M;
301 34 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
302 34 cheatkeys[Cheat::Rupies][0] = KEY_R;
303 34 cheatkeys[Cheat::Bombs][0] = KEY_B;
304 34 cheatkeys[Cheat::Arrows][0] = KEY_A;
305 34 cheatkeys[Cheat::Clock][0] = KEY_I;
306 34 cheatkeys[Cheat::Walls][0] = KEY_F11;
307 34 cheatkeys[Cheat::Fast][0] = KEY_Q;
308 34 cheatkeys[Cheat::Light][0] = KEY_L;
309 34 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
310 34 cheatkeys[Cheat::Kill][0] = KEY_K;
311 34 cheatkeys[Cheat::GoTo][0] = KEY_G;
312 34 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
313 34 cheatkeys[Cheat::ShowL0][0] = KEY_0;
314 34 cheatkeys[Cheat::ShowL1][0] = KEY_1;
315 34 cheatkeys[Cheat::ShowL2][0] = KEY_2;
316 34 cheatkeys[Cheat::ShowL3][0] = KEY_3;
317 34 cheatkeys[Cheat::ShowL4][0] = KEY_4;
318 34 cheatkeys[Cheat::ShowL5][0] = KEY_5;
319 34 cheatkeys[Cheat::ShowL6][0] = KEY_6;
320 34 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
321 34 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
322 34 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
323 34 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
324 34 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
325 34 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
326 34 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
327 34 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
328 34 }
329 34 void load_game_configs()
330 {
331 34 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
332 34 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
333 34 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
334 34 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
335 34 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
336 34 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
337 34 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
338 34 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
339 34 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
340 34 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
341 34 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
342 34 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
343 34 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
344 34 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
345 34 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
346
347 //cheat modifier keya
348 34 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
349 34 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
350 34 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
351 34 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
352
353 //cheat keys
354 34 load_default_cheatkeys();
355 char buf[256];
356
2/2
✓ Branch 0 taken 1190 times.
✓ Branch 1 taken 34 times.
1224 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 if(!bindable_cheat((Cheat)q)) continue;
359 1190 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 util::lowerstr(cheatname);
361 1190 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
363 1190 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
364
1/2
✓ Branch 0 taken 1190 times.
✗ Branch 1 not taken.
1190 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
365 1190 }
366
367
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
368 joystick_index = 0;
369
370 34 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
371 34 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
372 34 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
373 34 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
374 34 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
375 34 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
376 34 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
377 34 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
378 34 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
379 34 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
380
381 34 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
382 34 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
383 34 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
384 34 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
385
386 34 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
387 34 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
388 34 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
389 34 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
390 34 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
391 34 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
392 34 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
393 34 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
394 34 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
395 34 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
396 34 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
397
398 34 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
399 34 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
400 34 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
401 34 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
402
403 34 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
404
405 34 digi_volume = zc_get_config(sfx_sect,"digi",248);
406 34 midi_volume = zc_get_config(sfx_sect,"midi",255);
407 34 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
408 34 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
409 34 pan_style = zc_get_config(sfx_sect,"pan",1);
410 // 1 <= zcmusic_bufsz <= 128
411 34 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
412 34 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
413 34 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
414 34 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
415 34 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
416 34 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
417 34 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
418 #ifdef __EMSCRIPTEN__
419 if (em_is_mobile()) NameEntryMode = 2;
420 #endif
421 34 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
422 34 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
423 34 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
424 34 title_version = zc_get_config(cfg_sect,"title",2);
425 34 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
426 34 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
427
428 //default - scale x2, 640 x 480
429 34 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
430 34 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
431 34 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
432 34 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
433 34 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
434 34 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
435 34 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
436
437 34 loadlast = zc_get_config(cfg_sect,"load_last",0);
438
439 34 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
440
441 34 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
442
443 34 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
444 34 info_opacity = zc_get_config("zc","debug_info_opacity",255);
445 #ifdef _WIN32
446 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
447 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
448 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
449 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
450
451 // This one's for Aero
452 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
453
454 // And this one fixes patches unloading on some MIDI setups
455 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
456 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
457 #else //UNIX
458 34 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
459 34 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
460 34 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
461 #endif
462 34 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
463 34 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
464
465 34 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,""));
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(strlen(qstdir)==0)
468 {
469 34 getcwd(qstdir,2048);
470 34 fix_filename_case(qstdir);
471 34 fix_filename_slashes(qstdir);
472 34 put_backslash(qstdir);
473 34 }
474 else
475 {
476 chop_path(qstdir);
477 }
478
479 34 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
480 34 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
481 34 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
482 34 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
483 34 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
484 34 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
485 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
486 34 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
487 34 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
488 34 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
489 34 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
490 34 }
491
492 void save_control_configs(bool kb)
493 {
494 if(kb)
495 {
496 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
497 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
498 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
499 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
500
501 if (!replay_is_replaying())
502 {
503 zc_set_config(ctrl_sect,"key_a",Akey);
504 zc_set_config(ctrl_sect,"key_b",Bkey);
505 zc_set_config(ctrl_sect,"key_s",Skey);
506 zc_set_config(ctrl_sect,"key_l",Lkey);
507 zc_set_config(ctrl_sect,"key_r",Rkey);
508 zc_set_config(ctrl_sect,"key_p",Pkey);
509 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
510 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
511 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
512 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
513 zc_set_config(ctrl_sect,"key_up", DUkey);
514 zc_set_config(ctrl_sect,"key_down", DDkey);
515 zc_set_config(ctrl_sect,"key_left", DLkey);
516 zc_set_config(ctrl_sect,"key_right",DRkey);
517 }
518 }
519 else
520 {
521 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
522 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
523 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
524 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
525 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
526 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
527 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
528 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
529 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
530 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
531 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
532 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
533 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
534 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
535
536 zc_set_config(ctrl_sect,"btn_a",Abtn);
537 zc_set_config(ctrl_sect,"btn_b",Bbtn);
538 zc_set_config(ctrl_sect,"btn_s",Sbtn);
539 zc_set_config(ctrl_sect,"btn_m",Mbtn);
540 zc_set_config(ctrl_sect,"btn_l",Lbtn);
541 zc_set_config(ctrl_sect,"btn_r",Rbtn);
542 zc_set_config(ctrl_sect,"btn_p",Pbtn);
543 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
544 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
545 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
546 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
547
548 zc_set_config(ctrl_sect,"btn_up",DUbtn);
549 zc_set_config(ctrl_sect,"btn_down",DDbtn);
550 zc_set_config(ctrl_sect,"btn_left",DLbtn);
551 zc_set_config(ctrl_sect,"btn_right",DRbtn);
552 }
553 }
554
555 void save_cheatkeys()
556 {
557 char buf[256];
558 for(size_t q = 1; q < Cheat::Last; ++q)
559 {
560 if(!bindable_cheat((Cheat)q)) continue;
561 std::string cheatname = cheat_to_string((Cheat)q);
562 util::lowerstr(cheatname);
563 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
564 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
565 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
566 if(cheatkeys[q][1])
567 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
568 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
569 }
570 }
571
572 void save_game_configs()
573 {
574 packfile_password("");
575
576 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
577
578 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
579 {
580 int o_window_x, o_window_y;
581 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
582 zc_set_config(cfg_sect,"window_x",o_window_x);
583 zc_set_config(cfg_sect,"window_y",o_window_y);
584 }
585
586 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
587 {
588 double monitor_scale = zc_get_monitor_scale();
589 window_width = al_get_display_width(all_get_display()) / monitor_scale;
590 window_height = al_get_display_height(all_get_display()) / monitor_scale;
591 zc_set_config(cfg_sect,"window_width",window_width);
592 zc_set_config(cfg_sect,"window_height",window_height);
593 }
594
595 zc_set_config(cfg_sect,"load_last",loadlast);
596 chop_path(qstdir);
597 zc_set_config(cfg_sect,qst_dir_name,qstdir);
598 zc_set_config("SAVEFILE","save_filename",save_file_name);
599 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
600
601 flush_config_file();
602 #ifdef __EMSCRIPTEN__
603 em_sync_fs();
604 #endif
605 }
606
607 //----------------------------------------------------------------
608
609 // Timers
610
611 26958 void fps_callback()
612 {
613 26958 lastfps=framecnt;
614 26958 dword tempsecs = fps_secs;
615 26958 ++tempsecs;
616 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
617 26958 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
618 26958 ++fps_secs;
619 26958 framecnt=0;
620 26958 }
621
622 END_OF_FUNCTION(fps_callback)
623
624 34 int32_t Z_init_timers()
625 {
626 static bool didit = false;
627 const static char *err_str = "Couldn't allocate timer";
628 34 err_str = err_str; //Unused variable warning
629
630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(didit)
631 return 1;
632
633 34 didit = true;
634
635 LOCK_VARIABLE(lastfps);
636 LOCK_VARIABLE(framecnt);
637 LOCK_FUNCTION(fps_callback);
638
639
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
640 return 0;
641
642 34 return 1;
643 34 }
644
645 void Z_remove_timers()
646 {
647 remove_int(fps_callback);
648 }
649
650 //----------------------------------------------------------------
651
652 void go()
653 {
654 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
655 }
656
657 void comeback()
658 {
659 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
660 }
661
662 void dump_pal(BITMAP *dest)
663 {
664 for(int32_t i=0; i<256; i++)
665 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
666 }
667
668 //----------------------------------------------------------------
669
670 int game_mouse_index = ZCM_BLANK;
671 static bool system_mouse = false;
672 28 bool sys_mouse()
673 {
674 28 system_mouse = true;
675 28 return MouseSprite::set(ZCM_NORMAL);
676 }
677 460 bool game_mouse()
678 {
679 460 system_mouse = false;
680 460 return MouseSprite::set(game_mouse_index);
681 }
682 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
683 {
684 if(!bmp)
685 return;
686 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
687 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
688 if(bmp->w == scaledw && bmp->h == scaledh)
689 user_scale = false;
690 if(user_scale || sys_recolor)
691 {
692 if(!user_scale) scale = 1;
693 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
694 if(user_scale)
695 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
696 else
697 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
698 if(sys_recolor)
699 recolor_mouse(tmpbmp);
700 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
701 destroy_bitmap(tmpbmp);
702 }
703 else
704 {
705 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
706 }
707 }
708
709 //Handles converting the mouse sprite from the .dat file
710 34 void recolor_mouse(BITMAP* bmp)
711 {
712
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 34 times.
578 for(int32_t x = 0; x < bmp->w; ++x)
713 {
714
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 544 times.
9248 for(int32_t y = 0; y < bmp->h; ++y)
715 {
716 8704 int32_t color = getpixel(bmp, x, y);
717
5/5
✓ Branch 0 taken 5916 times.
✓ Branch 1 taken 646 times.
✓ Branch 2 taken 748 times.
✓ Branch 3 taken 782 times.
✓ Branch 4 taken 612 times.
8704 switch(color)
718 {
719 case dvc(1):
720 646 color = jwin_pal[jcCURSORMISC];
721 646 break;
722 case dvc(2):
723 748 color = jwin_pal[jcCURSOROUTLINE];
724 748 break;
725 case dvc(3):
726 782 color = jwin_pal[jcCURSORLIGHT];
727 782 break;
728 case dvc(5):
729 612 color = jwin_pal[jcCURSORDARK];
730 612 break;
731 default:
732 5916 continue;
733 }
734 2788 putpixel(bmp, x, y, color);
735 2788 }
736 544 }
737 34 }
738 34 void load_mouse()
739 {
740 34 system_pal();
741 34 MouseSprite::set(-1);
742 34 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
743 34 int32_t sz = 16*scale;
744
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 34 times.
68 for(int32_t j = 0; j < 1; ++j)
745 {
746 34 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
747
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(zcmouse[j])
748 destroy_bitmap(zcmouse[j]);
749 34 zcmouse[j] = create_bitmap_ex(8,sz,sz);
750 34 clear_bitmap(zcmouse[j]);
751 34 clear_bitmap(tmpbmp);
752 34 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
753 34 recolor_mouse(tmpbmp);
754
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(sz!=16)
755 34 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
756 else
757 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
758 34 destroy_bitmap(tmpbmp);
759 34 }
760 34 zc_set_palette(*hw_palette);
761
762 34 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
763 34 clear_bitmap(blankmouse);
764
765 34 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
766 34 MouseSprite::assign(ZCM_BLANK, blankmouse);
767 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
768
769 //Reload the mouse
770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(system_mouse)
771 sys_mouse();
772 34 else game_mouse();
773
774 34 destroy_bitmap(blankmouse);
775 34 game_pal();
776 34 }
777
778 // sets the video mode and initializes the palette and mouse sprite
779 34 bool game_vid_mode(int32_t mode,int32_t wait)
780 {
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
782 {
783 return false;
784 }
785
786 34 scrx = (resx-320)>>1;
787 34 scry = (resy-240)>>1;
788
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 34 times.
68 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
789 34 zcmouse[q] = NULL;
790 34 load_mouse();
791
792
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 34 times.
578 for(int32_t i=240; i<256; i++)
793 544 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
794
795 34 zc_set_palette(RAMpal);
796 34 clear_to_color(screen,BLACK);
797
798 34 rest(wait);
799 34 return true;
800 34 }
801
802 8 void null_quest()
803 {
804 char qstdat_string[2048];
805 8 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
806 8 strcat(qstdat_string,"#NESQST_NEW_QST");
807
808 #ifdef __EMSCRIPTEN__
809 // The quest template data file is not included because it's really big and isn't really needed
810 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
811 // which is much smaller.
812 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
813 #endif
814
815 8 byte skip_flags[4] = { 0 };
816
817 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,skip_flags,0,false);
818 8 }
819
820 // TODO remove
821 8 void init_NES_mode()
822 {
823 8 null_quest();
824 8 }
825
826 //----------------------------------------------------------------
827
828 qword trianglelines[16]=
829 {
830 0x0000000000000000ULL,
831 0xFD00000000000000ULL,
832 0xFDFD000000000000ULL,
833 0xFDFDFD0000000000ULL,
834 0xFDFDFDFD00000000ULL,
835 0xFDFDFDFDFD000000ULL,
836 0xFDFDFDFDFDFD0000ULL,
837 0xFDFDFDFDFDFDFD00ULL,
838 0xFDFDFDFDFDFDFDFDULL,
839 0x00FDFDFDFDFDFDFDULL,
840 0x0000FDFDFDFDFDFDULL,
841 0x000000FDFDFDFDFDULL,
842 0x00000000FDFDFDFDULL,
843 0x0000000000FDFDFDULL,
844 0x000000000000FDFDULL,
845 0x00000000000000FDULL,
846 };
847
848 word screen_triangles[28][32];
849 /*
850 qword triangles[4][16]= //[direction][value]
851 {
852 {
853 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
854 },
855 {
856 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
857 },
858 {
859 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
860 },
861 {
862 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
863 }
864 };
865 */
866
867
868 /*
869 byte triangles[4][16][8]= //[direction][value][line]
870 {
871 {
872 {
873 0, 0, 0, 0, 0, 0, 0, 0
874 },
875 {
876 1, 0, 0, 0, 0, 0, 0, 0
877 },
878 {
879 2, 1, 0, 0, 0, 0, 0, 0
880 },
881 {
882 3, 2, 1, 0, 0, 0, 0, 0
883 },
884 {
885 4, 3, 2, 1, 0, 0, 0, 0
886 },
887 {
888 5, 4, 3, 2, 1, 0, 0, 0
889 },
890 {
891 6, 5, 4, 3, 2, 1, 0, 0
892 },
893 {
894 7, 6, 5, 4, 3, 2, 1, 0
895 },
896 {
897 8, 7, 6, 5, 4, 3, 2, 1
898 },
899 {
900 8, 8, 7, 6, 5, 4, 3, 2
901 },
902 {
903 8, 8, 8, 7, 6, 5, 4, 3
904 },
905 {
906 8, 8, 8, 8, 7, 6, 5, 4
907 },
908 {
909 8, 8, 8, 8, 8, 7, 6, 5
910 },
911 {
912 8, 8, 8, 8, 8, 8, 7, 6
913 },
914 {
915 8, 8, 8, 8, 8, 8, 8, 7
916 },
917 {
918 8, 8, 8, 8, 8, 8, 8, 8
919 }
920 },
921 {
922 {
923 0, 0, 0, 0, 0, 0, 0, 0
924 },
925 {
926 15, 0, 0, 0, 0, 0, 0, 0
927 },
928 {
929 14, 15, 0, 0, 0, 0, 0, 0
930 },
931 {
932 13, 14, 15, 0, 0, 0, 0, 0
933 },
934 {
935 12, 13, 14, 15, 0, 0, 0, 0
936 },
937 {
938 11, 12, 13, 14, 15, 0, 0, 0
939 },
940 {
941 10, 11, 12, 13, 14, 15, 0, 0
942 },
943 {
944 9, 10, 11, 12, 13, 14, 15, 0
945 },
946 {
947 8, 9, 10, 11, 12, 13, 14, 15
948 },
949 {
950 8, 8, 9, 10, 11, 12, 13, 14
951 },
952 {
953 8, 8, 8, 9, 10, 11, 12, 13
954 },
955 {
956 8, 8, 8, 8, 9, 10, 11, 12
957 },
958 {
959 8, 8, 8, 8, 8, 9, 10, 11
960 },
961 {
962 8, 8, 8, 8, 8, 8, 9, 10
963 },
964 {
965 8, 8, 8, 8, 8, 8, 8, 9
966 },
967 {
968 8, 8, 8, 8, 8, 8, 8, 8
969 }
970 },
971 {
972 {
973 0, 0, 0, 0, 0, 0, 0, 0
974 },
975 {
976 0, 0, 0, 0, 0, 0, 0, 1
977 },
978 {
979 0, 0, 0, 0, 0, 0, 1, 2
980 },
981 {
982 0, 0, 0, 0, 0, 1, 2, 3
983 },
984 {
985 0, 0, 0, 0, 1, 2, 3, 4
986 },
987 {
988 0, 0, 0, 1, 2, 3, 4, 5
989 },
990 {
991 0, 0, 1, 2, 3, 4, 5, 6
992 },
993 {
994 0, 1, 2, 3, 4, 5, 6, 7
995 },
996 {
997 1, 2, 3, 4, 5, 6, 7, 8
998 },
999 {
1000 2, 3, 4, 5, 6, 7, 8, 8
1001 },
1002 {
1003 3, 4, 5, 6, 7, 8, 8, 8
1004 },
1005 {
1006 4, 5, 6, 7, 8, 8, 8, 8
1007 },
1008 {
1009 5, 6, 7, 8, 8, 8, 8, 8
1010 },
1011 {
1012 6, 7, 8, 8, 8, 8, 8, 8
1013 },
1014 {
1015 7, 8, 8, 8, 8, 8, 8, 8
1016 },
1017 {
1018 8, 8, 8, 8, 8, 8, 8, 8
1019 }
1020 },
1021 {
1022 {
1023 0, 0, 0, 0, 0, 0, 0, 0
1024 },
1025 {
1026 0, 0, 0, 0, 0, 0, 0, 15
1027 },
1028 {
1029 0, 0, 0, 0, 0, 0, 15, 14
1030 },
1031 {
1032 0, 0, 0, 0, 0, 15, 14, 13
1033 },
1034 {
1035 0, 0, 0, 0, 15, 14, 13, 12
1036 },
1037 {
1038 0, 0, 0, 15, 14, 13, 12, 11
1039 },
1040 {
1041 0, 0, 15, 14, 13, 12, 11, 10
1042 },
1043 {
1044 0, 15, 14, 13, 12, 11, 10, 9
1045 },
1046 {
1047 15, 14, 13, 12, 11, 10, 9, 8
1048 },
1049 {
1050 14, 13, 12, 11, 10, 9, 8, 8
1051 },
1052 {
1053 13, 12, 11, 10, 9, 8, 8, 8
1054 },
1055 {
1056 12, 11, 10, 9, 8, 8, 8, 8
1057 },
1058 {
1059 11, 10, 9, 8, 8, 8, 8, 8
1060 },
1061 {
1062 10, 9, 8, 8, 8, 8, 8, 8
1063 },
1064 {
1065 9, 8, 8, 8, 8, 8, 8, 8
1066 },
1067 {
1068 8, 8, 8, 8, 8, 8, 8, 8
1069 }
1070 }
1071 };
1072 */
1073
1074
1075
1076 /*
1077 for (int32_t blockrow=0; blockrow<30; ++i)
1078 {
1079 for (int32_t linerow=0; linerow<8; ++i)
1080 {
1081 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1082 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1083 {
1084 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1085 ++triangleline;
1086 }
1087 }
1088 }
1089 */
1090
1091 // the ULL suffixes are to prevent this warning:
1092 // warning: integer constant is too large for "int32_t" type
1093
1094 qword triangles[4][16][8]= //[direction][value][line]
1095 {
1096 {
1097 {
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL
1106 },
1107 {
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL
1116 },
1117 {
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL
1126 },
1127 {
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL,
1131 0x0000000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL,
1134 0x0000000000000000ULL,
1135 0x0000000000000000ULL
1136 },
1137 {
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL,
1141 0xFD00000000000000ULL,
1142 0x0000000000000000ULL,
1143 0x0000000000000000ULL,
1144 0x0000000000000000ULL,
1145 0x0000000000000000ULL
1146 },
1147 {
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL,
1151 0xFDFD000000000000ULL,
1152 0xFD00000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL
1156 },
1157 {
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL,
1161 0xFDFDFD0000000000ULL,
1162 0xFDFD000000000000ULL,
1163 0xFD00000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL
1166 },
1167 {
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL,
1171 0xFDFDFDFD00000000ULL,
1172 0xFDFDFD0000000000ULL,
1173 0xFDFD000000000000ULL,
1174 0xFD00000000000000ULL,
1175 0x0000000000000000ULL
1176 },
1177 {
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL,
1181 0xFDFDFDFDFD000000ULL,
1182 0xFDFDFDFD00000000ULL,
1183 0xFDFDFD0000000000ULL,
1184 0xFDFD000000000000ULL,
1185 0xFD00000000000000ULL
1186 },
1187 {
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL,
1191 0xFDFDFDFDFDFD0000ULL,
1192 0xFDFDFDFDFD000000ULL,
1193 0xFDFDFDFD00000000ULL,
1194 0xFDFDFD0000000000ULL,
1195 0xFDFD000000000000ULL
1196 },
1197 {
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFD00ULL,
1202 0xFDFDFDFDFDFD0000ULL,
1203 0xFDFDFDFDFD000000ULL,
1204 0xFDFDFDFD00000000ULL,
1205 0xFDFDFD0000000000ULL
1206 },
1207 {
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFD00ULL,
1213 0xFDFDFDFDFDFD0000ULL,
1214 0xFDFDFDFDFD000000ULL,
1215 0xFDFDFDFD00000000ULL
1216 },
1217 {
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFD00ULL,
1224 0xFDFDFDFDFDFD0000ULL,
1225 0xFDFDFDFDFD000000ULL
1226 },
1227 {
1228 0xFDFDFDFDFDFDFDFDULL,
1229 0xFDFDFDFDFDFDFDFDULL,
1230 0xFDFDFDFDFDFDFDFDULL,
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0xFDFDFDFDFDFDFDFDULL,
1233 0xFDFDFDFDFDFDFDFDULL,
1234 0xFDFDFDFDFDFDFD00ULL,
1235 0xFDFDFDFDFDFD0000ULL
1236 },
1237 {
1238 0xFDFDFDFDFDFDFDFDULL,
1239 0xFDFDFDFDFDFDFDFDULL,
1240 0xFDFDFDFDFDFDFDFDULL,
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0xFDFDFDFDFDFDFDFDULL,
1244 0xFDFDFDFDFDFDFDFDULL,
1245 0xFDFDFDFDFDFDFD00ULL
1246 },
1247 {
1248 0xFDFDFDFDFDFDFDFDULL,
1249 0xFDFDFDFDFDFDFDFDULL,
1250 0xFDFDFDFDFDFDFDFDULL,
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0xFDFDFDFDFDFDFDFDULL,
1255 0xFDFDFDFDFDFDFDFDULL
1256 }
1257 },
1258 {
1259 {
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL
1268 },
1269 {
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL
1278 },
1279 {
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL
1288 },
1289 {
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL,
1293 0x0000000000000000ULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL,
1296 0x0000000000000000ULL,
1297 0x0000000000000000ULL
1298 },
1299 {
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL,
1303 0x00000000000000FDULL,
1304 0x0000000000000000ULL,
1305 0x0000000000000000ULL,
1306 0x0000000000000000ULL,
1307 0x0000000000000000ULL
1308 },
1309 {
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL,
1313 0x000000000000FDFDULL,
1314 0x00000000000000FDULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL
1318 },
1319 {
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL,
1323 0x0000000000FDFDFDULL,
1324 0x000000000000FDFDULL,
1325 0x00000000000000FDULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL
1328 },
1329 {
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL,
1333 0x00000000FDFDFDFDULL,
1334 0x0000000000FDFDFDULL,
1335 0x000000000000FDFDULL,
1336 0x00000000000000FDULL,
1337 0x0000000000000000ULL
1338 },
1339 {
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL,
1343 0x000000FDFDFDFDFDULL,
1344 0x00000000FDFDFDFDULL,
1345 0x0000000000FDFDFDULL,
1346 0x000000000000FDFDULL,
1347 0x00000000000000FDULL
1348 },
1349 {
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL,
1353 0x0000FDFDFDFDFDFDULL,
1354 0x000000FDFDFDFDFDULL,
1355 0x00000000FDFDFDFDULL,
1356 0x0000000000FDFDFDULL,
1357 0x000000000000FDFDULL
1358 },
1359 {
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0x00FDFDFDFDFDFDFDULL,
1364 0x0000FDFDFDFDFDFDULL,
1365 0x000000FDFDFDFDFDULL,
1366 0x00000000FDFDFDFDULL,
1367 0x0000000000FDFDFDULL
1368 },
1369 {
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0x00FDFDFDFDFDFDFDULL,
1375 0x0000FDFDFDFDFDFDULL,
1376 0x000000FDFDFDFDFDULL,
1377 0x00000000FDFDFDFDULL
1378 },
1379 {
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0x00FDFDFDFDFDFDFDULL,
1386 0x0000FDFDFDFDFDFDULL,
1387 0x000000FDFDFDFDFDULL
1388 },
1389 {
1390 0xFDFDFDFDFDFDFDFDULL,
1391 0xFDFDFDFDFDFDFDFDULL,
1392 0xFDFDFDFDFDFDFDFDULL,
1393 0xFDFDFDFDFDFDFDFDULL,
1394 0xFDFDFDFDFDFDFDFDULL,
1395 0xFDFDFDFDFDFDFDFDULL,
1396 0x00FDFDFDFDFDFDFDULL,
1397 0x0000FDFDFDFDFDFDULL
1398 },
1399 {
1400 0xFDFDFDFDFDFDFDFDULL,
1401 0xFDFDFDFDFDFDFDFDULL,
1402 0xFDFDFDFDFDFDFDFDULL,
1403 0xFDFDFDFDFDFDFDFDULL,
1404 0xFDFDFDFDFDFDFDFDULL,
1405 0xFDFDFDFDFDFDFDFDULL,
1406 0xFDFDFDFDFDFDFDFDULL,
1407 0x00FDFDFDFDFDFDFDULL
1408 },
1409 {
1410 0xFDFDFDFDFDFDFDFDULL,
1411 0xFDFDFDFDFDFDFDFDULL,
1412 0xFDFDFDFDFDFDFDFDULL,
1413 0xFDFDFDFDFDFDFDFDULL,
1414 0xFDFDFDFDFDFDFDFDULL,
1415 0xFDFDFDFDFDFDFDFDULL,
1416 0xFDFDFDFDFDFDFDFDULL,
1417 0xFDFDFDFDFDFDFDFDULL
1418 }
1419 },
1420 {
1421 {
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0x0000000000000000ULL
1430 },
1431 {
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0x0000000000000000ULL,
1438 0x0000000000000000ULL,
1439 0xFD00000000000000ULL
1440 },
1441 {
1442 0x0000000000000000ULL,
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0x0000000000000000ULL,
1447 0x0000000000000000ULL,
1448 0xFD00000000000000ULL,
1449 0xFDFD000000000000ULL
1450 },
1451 {
1452 0x0000000000000000ULL,
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0x0000000000000000ULL,
1456 0x0000000000000000ULL,
1457 0xFD00000000000000ULL,
1458 0xFDFD000000000000ULL,
1459 0xFDFDFD0000000000ULL
1460 },
1461 {
1462 0x0000000000000000ULL,
1463 0x0000000000000000ULL,
1464 0x0000000000000000ULL,
1465 0x0000000000000000ULL,
1466 0xFD00000000000000ULL,
1467 0xFDFD000000000000ULL,
1468 0xFDFDFD0000000000ULL,
1469 0xFDFDFDFD00000000ULL
1470 },
1471 {
1472 0x0000000000000000ULL,
1473 0x0000000000000000ULL,
1474 0x0000000000000000ULL,
1475 0xFD00000000000000ULL,
1476 0xFDFD000000000000ULL,
1477 0xFDFDFD0000000000ULL,
1478 0xFDFDFDFD00000000ULL,
1479 0xFDFDFDFDFD000000ULL
1480 },
1481 {
1482 0x0000000000000000ULL,
1483 0x0000000000000000ULL,
1484 0xFD00000000000000ULL,
1485 0xFDFD000000000000ULL,
1486 0xFDFDFD0000000000ULL,
1487 0xFDFDFDFD00000000ULL,
1488 0xFDFDFDFDFD000000ULL,
1489 0xFDFDFDFDFDFD0000ULL
1490 },
1491 {
1492 0x0000000000000000ULL,
1493 0xFD00000000000000ULL,
1494 0xFDFD000000000000ULL,
1495 0xFDFDFD0000000000ULL,
1496 0xFDFDFDFD00000000ULL,
1497 0xFDFDFDFDFD000000ULL,
1498 0xFDFDFDFDFDFD0000ULL,
1499 0xFDFDFDFDFDFDFD00ULL
1500 },
1501 {
1502 0xFD00000000000000ULL,
1503 0xFDFD000000000000ULL,
1504 0xFDFDFD0000000000ULL,
1505 0xFDFDFDFD00000000ULL,
1506 0xFDFDFDFDFD000000ULL,
1507 0xFDFDFDFDFDFD0000ULL,
1508 0xFDFDFDFDFDFDFD00ULL,
1509 0xFDFDFDFDFDFDFDFDULL
1510 },
1511 {
1512 0xFDFD000000000000ULL,
1513 0xFDFDFD0000000000ULL,
1514 0xFDFDFDFD00000000ULL,
1515 0xFDFDFDFDFD000000ULL,
1516 0xFDFDFDFDFDFD0000ULL,
1517 0xFDFDFDFDFDFDFD00ULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL
1520 },
1521 {
1522 0xFDFDFD0000000000ULL,
1523 0xFDFDFDFD00000000ULL,
1524 0xFDFDFDFDFD000000ULL,
1525 0xFDFDFDFDFDFD0000ULL,
1526 0xFDFDFDFDFDFDFD00ULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL
1530 },
1531 {
1532 0xFDFDFDFD00000000ULL,
1533 0xFDFDFDFDFD000000ULL,
1534 0xFDFDFDFDFDFD0000ULL,
1535 0xFDFDFDFDFDFDFD00ULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL
1540 },
1541 {
1542 0xFDFDFDFDFD000000ULL,
1543 0xFDFDFDFDFDFD0000ULL,
1544 0xFDFDFDFDFDFDFD00ULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL
1550 },
1551 {
1552 0xFDFDFDFDFDFD0000ULL,
1553 0xFDFDFDFDFDFDFD00ULL,
1554 0xFDFDFDFDFDFDFDFDULL,
1555 0xFDFDFDFDFDFDFDFDULL,
1556 0xFDFDFDFDFDFDFDFDULL,
1557 0xFDFDFDFDFDFDFDFDULL,
1558 0xFDFDFDFDFDFDFDFDULL,
1559 0xFDFDFDFDFDFDFDFDULL
1560 },
1561 {
1562 0xFDFDFDFDFDFDFD00ULL,
1563 0xFDFDFDFDFDFDFDFDULL,
1564 0xFDFDFDFDFDFDFDFDULL,
1565 0xFDFDFDFDFDFDFDFDULL,
1566 0xFDFDFDFDFDFDFDFDULL,
1567 0xFDFDFDFDFDFDFDFDULL,
1568 0xFDFDFDFDFDFDFDFDULL,
1569 0xFDFDFDFDFDFDFDFDULL
1570 },
1571 {
1572 0xFDFDFDFDFDFDFDFDULL,
1573 0xFDFDFDFDFDFDFDFDULL,
1574 0xFDFDFDFDFDFDFDFDULL,
1575 0xFDFDFDFDFDFDFDFDULL,
1576 0xFDFDFDFDFDFDFDFDULL,
1577 0xFDFDFDFDFDFDFDFDULL,
1578 0xFDFDFDFDFDFDFDFDULL,
1579 0xFDFDFDFDFDFDFDFDULL
1580 }
1581 },
1582 {
1583 {
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x0000000000000000ULL
1592 },
1593 {
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x0000000000000000ULL,
1600 0x0000000000000000ULL,
1601 0x00000000000000FDULL
1602 },
1603 {
1604 0x0000000000000000ULL,
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x0000000000000000ULL,
1609 0x0000000000000000ULL,
1610 0x00000000000000FDULL,
1611 0x000000000000FDFDULL
1612 },
1613 {
1614 0x0000000000000000ULL,
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x0000000000000000ULL,
1618 0x0000000000000000ULL,
1619 0x00000000000000FDULL,
1620 0x000000000000FDFDULL,
1621 0x0000000000FDFDFDULL
1622 },
1623 {
1624 0x0000000000000000ULL,
1625 0x0000000000000000ULL,
1626 0x0000000000000000ULL,
1627 0x0000000000000000ULL,
1628 0x00000000000000FDULL,
1629 0x000000000000FDFDULL,
1630 0x0000000000FDFDFDULL,
1631 0x00000000FDFDFDFDULL
1632 },
1633 {
1634 0x0000000000000000ULL,
1635 0x0000000000000000ULL,
1636 0x0000000000000000ULL,
1637 0x00000000000000FDULL,
1638 0x000000000000FDFDULL,
1639 0x0000000000FDFDFDULL,
1640 0x00000000FDFDFDFDULL,
1641 0x000000FDFDFDFDFDULL
1642 },
1643 {
1644 0x0000000000000000ULL,
1645 0x0000000000000000ULL,
1646 0x00000000000000FDULL,
1647 0x000000000000FDFDULL,
1648 0x0000000000FDFDFDULL,
1649 0x00000000FDFDFDFDULL,
1650 0x000000FDFDFDFDFDULL,
1651 0x0000FDFDFDFDFDFDULL
1652 },
1653 {
1654 0x0000000000000000ULL,
1655 0x00000000000000FDULL,
1656 0x000000000000FDFDULL,
1657 0x0000000000FDFDFDULL,
1658 0x00000000FDFDFDFDULL,
1659 0x000000FDFDFDFDFDULL,
1660 0x0000FDFDFDFDFDFDULL,
1661 0x00FDFDFDFDFDFDFDULL
1662 },
1663 {
1664 0x00000000000000FDULL,
1665 0x000000000000FDFDULL,
1666 0x0000000000FDFDFDULL,
1667 0x00000000FDFDFDFDULL,
1668 0x000000FDFDFDFDFDULL,
1669 0x0000FDFDFDFDFDFDULL,
1670 0x00FDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL
1672 },
1673 {
1674 0x000000000000FDFDULL,
1675 0x0000000000FDFDFDULL,
1676 0x00000000FDFDFDFDULL,
1677 0x000000FDFDFDFDFDULL,
1678 0x0000FDFDFDFDFDFDULL,
1679 0x00FDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL
1682 },
1683 {
1684 0x0000000000FDFDFDULL,
1685 0x00000000FDFDFDFDULL,
1686 0x000000FDFDFDFDFDULL,
1687 0x0000FDFDFDFDFDFDULL,
1688 0x00FDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL
1692 },
1693 {
1694 0x00000000FDFDFDFDULL,
1695 0x000000FDFDFDFDFDULL,
1696 0x0000FDFDFDFDFDFDULL,
1697 0x00FDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL
1702 },
1703 {
1704 0x000000FDFDFDFDFDULL,
1705 0x0000FDFDFDFDFDFDULL,
1706 0x00FDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL
1712 },
1713 {
1714 0x0000FDFDFDFDFDFDULL,
1715 0x00FDFDFDFDFDFDFDULL,
1716 0xFDFDFDFDFDFDFDFDULL,
1717 0xFDFDFDFDFDFDFDFDULL,
1718 0xFDFDFDFDFDFDFDFDULL,
1719 0xFDFDFDFDFDFDFDFDULL,
1720 0xFDFDFDFDFDFDFDFDULL,
1721 0xFDFDFDFDFDFDFDFDULL
1722 },
1723 {
1724 0x00FDFDFDFDFDFDFDULL,
1725 0xFDFDFDFDFDFDFDFDULL,
1726 0xFDFDFDFDFDFDFDFDULL,
1727 0xFDFDFDFDFDFDFDFDULL,
1728 0xFDFDFDFDFDFDFDFDULL,
1729 0xFDFDFDFDFDFDFDFDULL,
1730 0xFDFDFDFDFDFDFDFDULL,
1731 0xFDFDFDFDFDFDFDFDULL
1732 },
1733 {
1734 0xFDFDFDFDFDFDFDFDULL,
1735 0xFDFDFDFDFDFDFDFDULL,
1736 0xFDFDFDFDFDFDFDFDULL,
1737 0xFDFDFDFDFDFDFDFDULL,
1738 0xFDFDFDFDFDFDFDFDULL,
1739 0xFDFDFDFDFDFDFDFDULL,
1740 0xFDFDFDFDFDFDFDFDULL,
1741 0xFDFDFDFDFDFDFDFDULL
1742 }
1743 }
1744 };
1745
1746 int32_t black_opening_count=0;
1747 int32_t black_opening_x,black_opening_y;
1748 int32_t black_opening_shape;
1749
1750 1134 int32_t choose_opening_shape()
1751 {
1752 // First, count how many bits are set
1753 1134 int32_t numBits=0;
1754 int32_t bitCounter;
1755
1756
2/2
✓ Branch 0 taken 5670 times.
✓ Branch 1 taken 1134 times.
6804 for(int32_t i=0; i<bosMAX; i++)
1757 {
1758
2/2
✓ Branch 0 taken 4320 times.
✓ Branch 1 taken 1350 times.
5670 if(COOLSCROLL&(1<<i))
1759 1350 numBits++;
1760 5670 }
1761
1762 // Shouldn't happen...
1763
1/2
✓ Branch 0 taken 1134 times.
✗ Branch 1 not taken.
1134 if(numBits==0)
1764 return bosCIRCLE;
1765
1766 // Pick a bit
1767 1134 bitCounter=zc_rand()%numBits+1;
1768
1769
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 26 times.
1426 for(int32_t i=0; i<bosMAX; i++)
1770 {
1771 // If this bit is set, decrement the bit counter
1772
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1264 times.
1400 if(COOLSCROLL&(1<<i))
1773 1264 bitCounter--;
1774
1775 // When the counter hits 0, return a value based on
1776 // which bit it stopped on.
1777 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1778
2/2
✓ Branch 0 taken 1108 times.
✓ Branch 1 taken 292 times.
1400 if(bitCounter==0)
1779 1108 return i;
1780 292 }
1781
1782 // Shouldn't be necessary, but the compiler might complain, at least
1783 26 return bosCIRCLE;
1784 1134 }
1785
1786 312 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1787 {
1788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312 times.
312 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1789
1790 312 int32_t w=256, h=224;
1791 312 int32_t blockrows=28, blockcolumns=32;
1792 312 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1793
1794
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 312 times.
9048 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1795 {
1796
2/2
✓ Branch 0 taken 279552 times.
✓ Branch 1 taken 8736 times.
288288 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1797 {
1798
2/2
✓ Branch 0 taken 148819 times.
✓ Branch 1 taken 130733 times.
279552 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1799 279552 }
1800 8736 }
1801
1802 312 black_opening_count = 66;
1803 312 black_opening_x = x;
1804 312 black_opening_y = y;
1805 312 lensclk = 0;
1806 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1807
1808
1809
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(black_opening_shape == bosFADEBLACK)
1810 {
1811 refreshTints();
1812 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1813 }
1814
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(wait)
1815 {
1816 FFCore.warpScriptCheck();
1817 for(int32_t i=0; i<66; i++)
1818 {
1819 draw_screen(tmpscr);
1820 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1821 advanceframe(true);
1822
1823 if(Quit)
1824 {
1825 break;
1826 }
1827 }
1828 }
1829 312 }
1830
1831 822 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1832 {
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 822 times.
822 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1834
1835 822 int32_t w=256, h=224;
1836 822 int32_t blockrows=28, blockcolumns=32;
1837 822 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1838
1839
2/2
✓ Branch 0 taken 23016 times.
✓ Branch 1 taken 822 times.
23838 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1840 {
1841
2/2
✓ Branch 0 taken 736512 times.
✓ Branch 1 taken 23016 times.
759528 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1842 {
1843
2/2
✓ Branch 0 taken 335267 times.
✓ Branch 1 taken 401245 times.
736512 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1844 736512 }
1845 23016 }
1846
1847 822 black_opening_count = -66;
1848 822 black_opening_x = x;
1849 822 black_opening_y = y;
1850 822 lensclk = 0;
1851
1/2
✓ Branch 0 taken 822 times.
✗ Branch 1 not taken.
822 if(black_opening_shape == bosFADEBLACK)
1852 {
1853 refreshTints();
1854 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1855 }
1856
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 627 times.
822 if(wait)
1857 {
1858 627 FFCore.warpScriptCheck();
1859
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 41382 times.
42009 for(int32_t i=0; i<66; i++)
1860 {
1861 41382 draw_screen(tmpscr);
1862 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1863 41382 advanceframe(true);
1864
1865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41382 times.
41382 if(Quit)
1866 {
1867 break;
1868 }
1869 41382 }
1870 627 }
1871 822 }
1872
1873 74844 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1874 {
1875 74844 clear_to_color(tmp_scr,BLACK);
1876 74844 int32_t w=256, h=224;
1877
1878
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 2838 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70488 times.
74844 switch(black_opening_shape)
1879 {
1880 case bosOVAL:
1881 {
1882 858 double new_w=(w/2)+abs(w/2-x);
1883 858 double new_h=(h/2)+abs(h/2-y);
1884 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1885 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1886 858 break;
1887 }
1888
1889 case bosTRIANGLE:
1890 {
1891 660 double new_w=(w/2)+abs(w/2-x);
1892 660 double new_h=(h/2)+abs(h/2-y);
1893 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1894 660 double P2= (PI/2);
1895 660 double P23=(2*PI/3);
1896 660 double P43=(4*PI/3);
1897 660 double Pa= (-4*PI*a/(3*max_a));
1898 660 double angle=P2+Pa;
1899 660 double a0=angle;
1900 660 double a2=angle+P23;
1901 660 double a4=angle+P43;
1902 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1903 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1904 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1905 0);
1906 660 break;
1907 }
1908
1909 case bosSMAS:
1910 {
1911
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 1386 times.
2838 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1912
1913
2/2
✓ Branch 0 taken 79464 times.
✓ Branch 1 taken 2838 times.
82302 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1914 {
1915
2/2
✓ Branch 0 taken 635712 times.
✓ Branch 1 taken 79464 times.
715176 for(int32_t linerow=0; linerow<8; ++linerow)
1916 {
1917 635712 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1918
1919
2/2
✓ Branch 0 taken 20342784 times.
✓ Branch 1 taken 635712 times.
20978496 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1920 {
1921 61028352 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1922
6/6
✓ Branch 0 taken 14117840 times.
✓ Branch 1 taken 6224944 times.
✓ Branch 2 taken 13330568 times.
✓ Branch 3 taken 7012216 times.
✓ Branch 4 taken 7105624 times.
✓ Branch 5 taken 6224944 times.
20342784 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1923 20342784 [linerow];
1924 20342784 ++triangleline;
1925
1926
2/2
✓ Branch 0 taken 17799936 times.
✓ Branch 1 taken 2542848 times.
20342784 if(linerow==0)
1927 {
1928 2542848 }
1929 20342784 }
1930 635712 }
1931 79464 }
1932
1933 2838 break;
1934 }
1935
1936 case bosFADEBLACK:
1937 {
1938 if(black_opening_count<0)
1939 {
1940 black_fade(zc_min(-black_opening_count,63));
1941 }
1942 else if(black_opening_count>0)
1943 {
1944 black_fade(63-zc_max(black_opening_count-3,0));
1945 }
1946 else black_fade(0);
1947 return; //no blitting from tmp_scr!
1948 }
1949
1950 70488 case bosCIRCLE:
1951 default:
1952 {
1953 70488 double new_w=(w/2)+abs(w/2-x);
1954 70488 double new_h=(h/2)+abs(h/2-y);
1955 70488 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1956 //circlefill(tmp_scr,x,y,a<<3,0);
1957 70488 circlefill(tmp_scr,x,y,r,0);
1958 70488 break;
1959 }
1960 }
1961
1962 74844 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1963 74844 }
1964
1965
1966 void black_fade(int32_t fadeamnt)
1967 {
1968 for(int32_t i=0; i < 0xEF; i++)
1969 {
1970 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1971 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1972 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1973 }
1974
1975 refreshpal = true;
1976 }
1977
1978 //----------------------------------------------------------------
1979
1980 32885149 bool item_disabled(int32_t item) //is this item disabled?
1981 {
1982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32885149 times.
32885149 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1983 }
1984
1985 6715712 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1986 {
1987
2/2
✓ Branch 0 taken 80417 times.
✓ Branch 1 taken 6635295 times.
6715712 if(current_item(item_type, true) >=item)
1988 {
1989 80417 return true;
1990 }
1991
1992 6635295 return false;
1993 6715712 }
1994
1995 27684622 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1996 {
1997
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5076266 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3051917 times.
✓ Branch 6 taken 14718458 times.
✓ Branch 7 taken 4803303 times.
✓ Branch 8 taken 34678 times.
27684622 switch(item_type)
1998 {
1999 case itype_bomb:
2000 case itype_sbomb:
2001 {
2002 int32_t itemid = getItemID(itemsbuf, item_type, it);
2003
2004 if(itemid == -1)
2005 return false;
2006
2007 return (game->get_item(itemid));
2008 }
2009
2010 case itype_clock:
2011 {
2012 5076266 int32_t itemid = getItemID(itemsbuf, item_type, it);
2013
2014
2/4
✓ Branch 0 taken 5076266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5076266 times.
✗ Branch 3 not taken.
5076266 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
2015 return (game->get_item(itemid));
2016 5076266 return Hero.getClock()?1:0;
2017 }
2018
2019 case itype_key:
2020 return (game->get_keys()>0);
2021
2022 case itype_magiccontainer:
2023 return (game->get_maxmagic()>=game->get_mp_per_block());
2024
2025 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
2026 {
2027
1/3
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3051917 switch(it)
2028 {
2029 case -2:
2030 {
2031 for(int32_t i=0; i<MAXLEVELS; i++)
2032 {
2033 if(game->lvlitems[i]&liTRIFORCE)
2034 {
2035 return true;
2036 }
2037 }
2038
2039 return false;
2040 }
2041
2042 case -1:
2043 return (game->lvlitems[dlevel]&liTRIFORCE);
2044
2045 default:
2046
2/4
✓ Branch 0 taken 3051917 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3051917 times.
3051917 if(it>=0&&it<MAXLEVELS)
2047 {
2048 3051917 return (game->lvlitems[it]&liTRIFORCE);
2049 }
2050
2051 break;
2052 }
2053
2054 return 0;
2055 }
2056
2057 case itype_map: //it: -2=any, -1=current level, other=that level
2058 {
2059
1/3
✓ Branch 0 taken 14718458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
14718458 switch(it)
2060 {
2061 case -2:
2062 {
2063 for(int32_t i=0; i<MAXLEVELS; i++)
2064 {
2065 if(game->lvlitems[i]&liMAP)
2066 {
2067 return true;
2068 }
2069 }
2070
2071 return false;
2072 }
2073
2074 case -1:
2075 return (game->lvlitems[dlevel]&liMAP)!=0;
2076
2077 default:
2078
2/4
✓ Branch 0 taken 14718458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14718458 times.
14718458 if(it>=0&&it<MAXLEVELS)
2079 {
2080 14718458 return (game->lvlitems[it]&liMAP)!=0;
2081 }
2082
2083 break;
2084 }
2085
2086 return 0;
2087 }
2088
2089 case itype_compass: //it: -2=any, -1=current level, other=that level
2090 {
2091
1/3
✓ Branch 0 taken 4803303 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
4803303 switch(it)
2092 {
2093 case -2:
2094 {
2095 for(int32_t i=0; i<MAXLEVELS; i++)
2096 {
2097 if(game->lvlitems[i]&liCOMPASS)
2098 {
2099 return true;
2100 }
2101 }
2102
2103 return false;
2104 }
2105
2106 case -1:
2107 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2108
2109 default:
2110
2/4
✓ Branch 0 taken 4803303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4803303 times.
✗ Branch 3 not taken.
4803303 if(it>=0&&it<MAXLEVELS)
2111 {
2112 4803303 return (game->lvlitems[it]&liCOMPASS)!=0;
2113 }
2114
2115 break;
2116 }
2117 return 0;
2118 }
2119
2120 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2121 {
2122
1/3
✓ Branch 0 taken 34678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
34678 switch(it)
2123 {
2124 case -2:
2125 {
2126 for(int32_t i=0; i<MAXLEVELS; i++)
2127 {
2128 if(game->lvlitems[i]&liBOSSKEY)
2129 {
2130 return true;
2131 }
2132 }
2133
2134 return false;
2135 }
2136
2137 case -1:
2138 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2139
2140 default:
2141
2/4
✓ Branch 0 taken 34678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34678 times.
34678 if(it>=0&&it<MAXLEVELS)
2142 {
2143 34678 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2144 }
2145 break;
2146 }
2147 return 0;
2148 }
2149
2150 default:
2151 //it=(1<<(it-1));
2152 /*if (item_type>=itype_max)
2153 {
2154 system_pal();
2155 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2156 game_pal();
2157
2158 return false;
2159 }*/
2160 int32_t itemid = getItemID(itemsbuf, item_type, it);
2161
2162 if(itemid == -1)
2163 return false;
2164
2165 return game->get_item(itemid);
2166 }
2167 27684622 }
2168
2169
2170 86613099 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2171 {
2172
9/9
✓ Branch 0 taken 5076266 times.
✓ Branch 1 taken 46002971 times.
✓ Branch 2 taken 5076266 times.
✓ Branch 3 taken 5076266 times.
✓ Branch 4 taken 5076266 times.
✓ Branch 5 taken 5076266 times.
✓ Branch 6 taken 5076266 times.
✓ Branch 7 taken 5076266 times.
✓ Branch 8 taken 5076266 times.
86613099 switch(item_type)
2173 {
2174 case itype_clock:
2175 {
2176 5076266 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2177
2178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5076266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5076266 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2179 return itemsbuf[maxid].fam_type;
2180
2181 5076266 return has_item(itype_clock,1) ? 1 : 0;
2182 }
2183
2184 case itype_key:
2185 5076266 return game->get_keys();
2186
2187 case itype_lkey:
2188 5076266 return game->lvlkeys[get_dlevel()];
2189
2190 case itype_magiccontainer:
2191 5076266 return game->get_maxmagic()/game->get_mp_per_block();
2192
2193 case itype_triforcepiece:
2194 {
2195 5076266 int32_t count=0;
2196
2197
2/2
✓ Branch 0 taken 2599048192 times.
✓ Branch 1 taken 5076266 times.
2604124458 for(int32_t i=0; i<MAXLEVELS; i++)
2198 {
2199 2599048192 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2200 2599048192 }
2201
2202 5076266 return count;
2203 }
2204
2205 case itype_map:
2206 {
2207 5076266 int32_t count=0;
2208
2209
2/2
✓ Branch 0 taken 2599048192 times.
✓ Branch 1 taken 5076266 times.
2604124458 for(int32_t i=0; i<MAXLEVELS; i++)
2210 {
2211 2599048192 count+=(game->lvlitems[i]&liMAP)?1:0;
2212 2599048192 }
2213
2214 5076266 return count;
2215 }
2216
2217 case itype_compass:
2218 {
2219 5076266 int32_t count=0;
2220
2221
2/2
✓ Branch 0 taken 2599048192 times.
✓ Branch 1 taken 5076266 times.
2604124458 for(int32_t i=0; i<MAXLEVELS; i++)
2222 {
2223 2599048192 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2224 2599048192 }
2225
2226 5076266 return count;
2227 }
2228
2229 case itype_bosskey:
2230 {
2231 5076266 int32_t count=0;
2232
2233
2/2
✓ Branch 0 taken 2599048192 times.
✓ Branch 1 taken 5076266 times.
2604124458 for(int32_t i=0; i<MAXLEVELS; i++)
2234 {
2235 2599048192 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2236 2599048192 }
2237
2238 5076266 return count;
2239 }
2240
2241 default:
2242 46002971 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2243
2244
2/2
✓ Branch 0 taken 8708246 times.
✓ Branch 1 taken 37294725 times.
46002971 if(maxid == -1)
2245 37294725 return 0;
2246
2247 8708246 return itemsbuf[maxid].fam_type;
2248 }
2249 86613099 }
2250
2251 79897387 int32_t current_item(int32_t item_type) //item currently being used
2252 {
2253 79897387 return current_item(item_type, true);
2254 }
2255
2256 34 std::map<int32_t, int32_t> itemcache;
2257
2258 // Not actually used by anything at the moment...
2259 void removeFromItemCache(int32_t itemclass)
2260 {
2261 itemcache.erase(itemclass);
2262 }
2263
2264 24266 void flushItemCache()
2265 {
2266 24266 itemcache.clear();
2267
2268 //also fix the active subscreen if items were deleted -DD
2269
1/2
✓ Branch 0 taken 24266 times.
✗ Branch 1 not taken.
24266 if(game != NULL)
2270 {
2271 24266 verifyBothWeapons();
2272 24266 load_Sitems(&QMisc);
2273 24266 }
2274 24266 }
2275
2276 // This is used often, so it should be as direct as possible.
2277 2829370548 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2278 {
2279
2/2
✓ Branch 0 taken 2770917201 times.
✓ Branch 1 taken 58453347 times.
2829370548 if(jinx_check)
2280 {
2281
4/4
✓ Branch 0 taken 38292145 times.
✓ Branch 1 taken 20161202 times.
✓ Branch 2 taken 34628481 times.
✓ Branch 3 taken 3663664 times.
58453347 if(!(HeroSwordClk() || HeroItemClk()))
2282 34628481 jinx_check = false; //not jinxed
2283 58453347 }
2284
4/4
✓ Branch 0 taken 2805149170 times.
✓ Branch 1 taken 24221378 times.
✓ Branch 2 taken 23650363 times.
✓ Branch 3 taken 2781498807 times.
2829370548 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2285 {
2286 2781498807 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2287
2288
2/2
✓ Branch 0 taken 2769110190 times.
✓ Branch 1 taken 12388617 times.
2781498807 if(res != itemcache.end())
2289 2769110190 return res->second;
2290 12388617 }
2291
2292 60260358 int32_t result = -1;
2293 60260358 int32_t highestlevel = -1;
2294
2295
2/2
✓ Branch 0 taken 15426651648 times.
✓ Branch 1 taken 60260358 times.
15486912006 for(int32_t i=0; i<MAXITEMS; i++)
2296 {
2297
5/6
✓ Branch 0 taken 1197943844 times.
✓ Branch 1 taken 14228707804 times.
✓ Branch 2 taken 17819112 times.
✓ Branch 3 taken 1180124732 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17819112 times.
15426651648 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2298 {
2299
4/4
✓ Branch 0 taken 5189620 times.
✓ Branch 1 taken 12629492 times.
✓ Branch 2 taken 1358167 times.
✓ Branch 3 taken 16460945 times.
17819112 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2300 {
2301 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2302
2/2
✓ Branch 0 taken 16460788 times.
✓ Branch 1 taken 157 times.
16460945 if(!checkmagiccost(i))
2303 {
2304
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 145 times.
157 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2305 12 }
2306 16460800 }
2307
6/6
✓ Branch 0 taken 15432381 times.
✓ Branch 1 taken 2386586 times.
✓ Branch 2 taken 256688 times.
✓ Branch 3 taken 2129898 times.
✓ Branch 4 taken 1627257 times.
✓ Branch 5 taken 759329 times.
17818967 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2308 {
2309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 759329 times.
759329 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2310 759329 continue;
2311 }
2312
2313
2/2
✓ Branch 0 taken 237659 times.
✓ Branch 1 taken 16821979 times.
17059638 if(itemsbuf[i].fam_type >= highestlevel)
2314 {
2315 16821979 highestlevel = itemsbuf[i].fam_type;
2316 16821979 result=i;
2317 16821979 }
2318 17059638 }
2319 15425892174 }
2320
2321
2/2
✓ Branch 0 taken 23824866 times.
✓ Branch 1 taken 36435492 times.
60260358 if(!jinx_check) //Can't cache jinx_check results
2322 36435492 itemcache[itemtype] = result;
2323 60260358 return result;
2324 2829370548 }
2325
2326 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2327 2805863128 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2328 {
2329 2805863128 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2330
2/2
✓ Branch 0 taken 34945927 times.
✓ Branch 1 taken 2770917201 times.
2805863128 if(!jinx_check) //If not already a jinx-immune-only check...
2331 {
2332 //And the player IS jinxed...
2333
4/4
✓ Branch 0 taken 2751021583 times.
✓ Branch 1 taken 19895618 times.
✓ Branch 2 taken 3611802 times.
✓ Branch 3 taken 2747409781 times.
2770917201 if(HeroSwordClk() || HeroItemClk())
2334 {
2335 //Then do a jinx-immune-only check here
2336 23507420 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2337 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2338 //Should NOT need a compat rule, as this should always return -1 in old quests.
2339
2/2
✓ Branch 0 taken 1102644 times.
✓ Branch 1 taken 22404776 times.
23507420 if(ret2 > -1) return ret2;
2340 22404776 }
2341 2769814557 }
2342 2804760484 return ret;
2343 2805863128 }
2344 17663008 int32_t current_item_power(int32_t itemtype)
2345 {
2346 17663008 int32_t result = current_item_id(itemtype,true);
2347
2/2
✓ Branch 0 taken 13153281 times.
✓ Branch 1 taken 4509727 times.
17663008 return (result<0) ? 0 : itemsbuf[result].power;
2348 }
2349
2350 7 int32_t heart_container_id()
2351 {
2352
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2353 {
2354
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2355 {
2356 7 return i;
2357 }
2358 196 }
2359 return -1;
2360 7 }
2361
2362 5076266 int32_t item_tile_mod()
2363 {
2364 5076266 int32_t tile=0;
2365
2366
2/2
✓ Branch 0 taken 1065223 times.
✓ Branch 1 taken 4011043 times.
5076266 if(game->get_bombs())
2367 {
2368 4011043 int32_t itemid = current_item_id(itype_bomb,false);
2369
3/4
✓ Branch 0 taken 3929984 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3929984 times.
4011043 if(itemid > -1 && checkbunny(itemid))
2370 3929984 tile+=itemsbuf[itemid].ltm;
2371 4011043 }
2372
2373
2/2
✓ Branch 0 taken 3905832 times.
✓ Branch 1 taken 1170434 times.
5076266 if(game->get_sbombs())
2374 {
2375 1170434 int32_t itemid = current_item_id(itype_sbomb,false);
2376
3/4
✓ Branch 0 taken 1169006 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1169006 times.
1170434 if(itemid > -1 && checkbunny(itemid))
2377 1169006 tile+=itemsbuf[itemid].ltm;
2378 1170434 }
2379
2380
2/2
✓ Branch 0 taken 4972323 times.
✓ Branch 1 taken 103943 times.
5076266 if(current_item(itype_clock))
2381 {
2382 103943 int32_t itemid =
2383
1/2
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
103943 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2384 ? iClock
2385 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2386
2/4
✓ Branch 0 taken 103943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103943 times.
103943 if(itemid > -1 && checkbunny(itemid))
2387 103943 tile+=itemsbuf[itemid].ltm;
2388 103943 }
2389
2390
2/2
✓ Branch 0 taken 4030354 times.
✓ Branch 1 taken 1045912 times.
5076266 if(current_item(itype_key))
2391 {
2392 1045912 int32_t itemid =
2393
1/2
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
1045912 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2394 ? iKey
2395 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2396
2/4
✓ Branch 0 taken 1045912 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1045912 times.
1045912 if(itemid > -1 && checkbunny(itemid))
2397 1045912 tile+=itemsbuf[itemid].ltm;
2398 1045912 }
2399
2400
2/2
✓ Branch 0 taken 4903735 times.
✓ Branch 1 taken 172531 times.
5076266 if(current_item(itype_lkey))
2401 {
2402 172531 int32_t itemid =
2403
2/2
✓ Branch 0 taken 171621 times.
✓ Branch 1 taken 910 times.
172531 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2404 ? iLevelKey
2405 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2406
2/4
✓ Branch 0 taken 172531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 172531 times.
172531 if(itemid > -1 && checkbunny(itemid))
2407 172531 tile+=itemsbuf[itemid].ltm;
2408 172531 }
2409
2410
2/2
✓ Branch 0 taken 1040790 times.
✓ Branch 1 taken 4035476 times.
5076266 if(current_item(itype_map))
2411 {
2412 4035476 int32_t itemid =
2413
2/2
✓ Branch 0 taken 4034690 times.
✓ Branch 1 taken 786 times.
4035476 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2414 ? iMap
2415 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2416
2/4
✓ Branch 0 taken 4035476 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4035476 times.
4035476 if(itemid > -1 && checkbunny(itemid))
2417 4035476 tile+=itemsbuf[itemid].ltm;
2418 4035476 }
2419
2420
2/2
✓ Branch 0 taken 1018908 times.
✓ Branch 1 taken 4057358 times.
5076266 if(current_item(itype_compass))
2421 {
2422 4057358 int32_t itemid =
2423
2/2
✓ Branch 0 taken 3976299 times.
✓ Branch 1 taken 81059 times.
4057358 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2424 ? iCompass
2425 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2426
2/4
✓ Branch 0 taken 4057358 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4057358 times.
4057358 if(itemid > -1 && checkbunny(itemid))
2427 4057358 tile+=itemsbuf[itemid].ltm;
2428 4057358 }
2429
2430
2/2
✓ Branch 0 taken 3207062 times.
✓ Branch 1 taken 1869204 times.
5076266 if(current_item(itype_bosskey))
2431 {
2432 1869204 int32_t itemid =
2433
1/2
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
1869204 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2434 ? iBossKey
2435 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2436
2/4
✓ Branch 0 taken 1869204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1869204 times.
1869204 if(itemid > -1 && checkbunny(itemid))
2437 1869204 tile+=itemsbuf[itemid].ltm;
2438 1869204 }
2439
2440
2/2
✓ Branch 0 taken 2921151 times.
✓ Branch 1 taken 2155115 times.
5076266 if(current_item(itype_magiccontainer))
2441 {
2442 2155115 int32_t itemid =
2443
2/2
✓ Branch 0 taken 2062128 times.
✓ Branch 1 taken 92987 times.
2155115 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2444 ? iMagicC
2445 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2446
3/4
✓ Branch 0 taken 2155115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 2153245 times.
2155115 if(itemid > -1 && checkbunny(itemid))
2447 2153245 tile+=itemsbuf[itemid].ltm;
2448 2155115 }
2449
2450
2/2
✓ Branch 0 taken 1376973 times.
✓ Branch 1 taken 3699293 times.
5076266 if(current_item(itype_triforcepiece))
2451 {
2452 3699293 int32_t itemid =
2453
1/2
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
3699293 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2454 ? iTriforce
2455 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2456
2/4
✓ Branch 0 taken 3699293 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3699293 times.
3699293 if(itemid > -1 && checkbunny(itemid))
2457 3699293 tile+=itemsbuf[itemid].ltm;
2458 3699293 }
2459
2460
2/2
✓ Branch 0 taken 5076266 times.
✓ Branch 1 taken 2599048192 times.
2604124458 for(int32_t i=0; i<itype_max; i++)
2461 {
2462
2/2
✓ Branch 0 taken 2540776448 times.
✓ Branch 1 taken 58271744 times.
2599048192 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2463 {
2464
2/2
✓ Branch 0 taken 1138120 times.
✓ Branch 1 taken 57133624 times.
58271744 switch(i)
2465 {
2466 case itype_bomb:
2467 case itype_sbomb:
2468 case itype_clock:
2469 case itype_key:
2470 case itype_lkey:
2471 case itype_map:
2472 case itype_compass:
2473 case itype_bosskey:
2474 case itype_magiccontainer:
2475 case itype_triforcepiece:
2476 1138120 continue; //already handled
2477 }
2478 57133624 }
2479 2597910072 int32_t itemid = current_item_id(i,false);
2480
2/2
✓ Branch 0 taken 2592833806 times.
✓ Branch 1 taken 5076266 times.
2597910072 if(i == itype_shield)
2481 5076266 itemid = getCurrentShield(false);
2482
2483
4/4
✓ Branch 0 taken 70935188 times.
✓ Branch 1 taken 2526974884 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 70834207 times.
2597910072 if(itemid < 0 || !checkbunny(itemid))
2484 2527075865 continue;
2485
2486 70834207 itemdata const& itm = itemsbuf[itemid];
2487
2488
2/2
✓ Branch 0 taken 66371614 times.
✓ Branch 1 taken 4462593 times.
70834207 switch(itm.family)
2489 {
2490 case itype_shield:
2491
1/2
✓ Branch 0 taken 4462593 times.
✗ Branch 1 not taken.
4462593 if(itm.flags & ITEM_FLAG9) //active shield
2492 {
2493 if(!usingActiveShield(itemid))
2494 {
2495 tile+=itm.misc6; //'Inactive PTM'
2496 continue;
2497 }
2498 }
2499 4462593 break;
2500 }
2501
2502 70834207 tile+=itm.ltm;
2503 70834207 }
2504
2505 5076266 return tile;
2506 }
2507
2508 5076266 int32_t bunny_tile_mod()
2509 {
2510
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 5074396 times.
5076266 if(Hero.BunnyClock())
2511 {
2512 1870 return game->get_bunny_ltm();
2513 }
2514 5074396 return 0;
2515 5076266 }
2516
2517 // Hints are drawn on a separate layer to combo reveals.
2518 16332 void draw_lens_under(BITMAP *dest, bool layer)
2519 {
2520 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2521 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2522 //Lens flag 3: Don't show armos/chest/dive items
2523 //Lens flag 4: Show Raft Paths
2524 //Lens flag 5: Show Invisible Enemies
2525
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2526
2527 16332 int32_t strike_hint_table[11]=
2528 {
2529 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2530 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2531 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2532 };
2533
2534 // int32_t page = tmpscr->cpage;
2535 {
2536 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2537 // int32_t temptimer=0;
2538 16332 int32_t tempitem, tempweapon=0;
2539 16332 strike_hint=strike_hint_table[strike_hint_counter];
2540
2541
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2542 {
2543 492 strike_hint_timer=0;
2544 492 strike_hint_counter=((strike_hint_counter+1)%11);
2545 492 }
2546
2547 16332 ++strike_hint_timer;
2548
2549
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2550 {
2551 2874432 int32_t x = (i & 15) << 4;
2552 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2553 2874432 int32_t tempitemx=-16, tempitemy=-16;
2554 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2555
2556
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2557 {
2558 5748864 int32_t checkflag=0;
2559
2560
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2561 {
2562 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2563 2874432 }
2564 else
2565 {
2566 2874432 checkflag=tmpscr->sflag[i];
2567 }
2568
2569
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2570 {
2571
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2572 {
2573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2574 906 }
2575 else
2576 {
2577 192 checkflag = strike_hint;
2578 }
2579 1098 }
2580
2581
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2582 {
2583 case 0:
2584 case mfZELDA:
2585 case mfPUSHED:
2586 case mfENEMY0:
2587 case mfENEMY1:
2588 case mfENEMY2:
2589 case mfENEMY3:
2590 case mfENEMY4:
2591 case mfENEMY5:
2592 case mfENEMY6:
2593 case mfENEMY7:
2594 case mfENEMY8:
2595 case mfENEMY9:
2596 case mfSINGLE:
2597 case mfSINGLE16:
2598 case mfNOENEMY:
2599 case mfTRAP_H:
2600 case mfTRAP_V:
2601 case mfTRAP_4:
2602 case mfTRAP_LR:
2603 case mfTRAP_UD:
2604 case mfNOGROUNDENEMY:
2605 case mfNOBLOCKS:
2606 case mfSCRIPT1:
2607 case mfSCRIPT2:
2608 case mfSCRIPT3:
2609 case mfSCRIPT4:
2610 case mfSCRIPT5:
2611 case mfSCRIPT6:
2612 case mfSCRIPT7:
2613 case mfSCRIPT8:
2614 case mfSCRIPT9:
2615 case mfSCRIPT10:
2616 case mfSCRIPT11:
2617 case mfSCRIPT12:
2618 case mfSCRIPT13:
2619 case mfSCRIPT14:
2620 case mfSCRIPT15:
2621 case mfSCRIPT16:
2622 case mfSCRIPT17:
2623 case mfSCRIPT18:
2624 case mfSCRIPT19:
2625 case mfSCRIPT20:
2626 case mfPITHOLE:
2627 case mfPITFALLFLOOR:
2628 case mfLAVA:
2629 case mfICE:
2630 case mfICEDAMAGE:
2631 case mfDAMAGE1:
2632 case mfDAMAGE2:
2633 case mfDAMAGE4:
2634 case mfDAMAGE8:
2635 case mfDAMAGE16:
2636 case mfDAMAGE32:
2637 case mfFREEZEALL:
2638 case mfFREZEALLANSFFCS:
2639 case mfFREEZEFFCSOLY:
2640 case mfSCRITPTW1TRIG:
2641 case mfSCRITPTW2TRIG:
2642 case mfSCRITPTW3TRIG:
2643 case mfSCRITPTW4TRIG:
2644 case mfSCRITPTW5TRIG:
2645 case mfSCRITPTW6TRIG:
2646 case mfSCRITPTW7TRIG:
2647 case mfSCRITPTW8TRIG:
2648 case mfSCRITPTW9TRIG:
2649 case mfSCRITPTW10TRIG:
2650 case mfTROWEL:
2651 case mfTROWELNEXT:
2652 case mfTROWELSPECIALITEM:
2653 case mfSLASHPOT:
2654 case mfLIFTPOT:
2655 case mfLIFTORSLASH:
2656 case mfLIFTROCK:
2657 case mfLIFTROCKHEAVY:
2658 case mfDROPITEM:
2659 case mfSPECIALITEM:
2660 case mfDROPKEY:
2661 case mfDROPLKEY:
2662 case mfDROPCOMPASS:
2663 case mfDROPMAP:
2664 case mfDROPBOSSKEY:
2665 case mfSPAWNNPC:
2666 case mfSWITCHHOOK:
2667 case mfSIDEVIEWLADDER:
2668 case mfSIDEVIEWPLATFORM:
2669 case mfNOENEMYSPAWN:
2670 case mfENEMYALL:
2671 case mfNOMIRROR:
2672 case mfUNSAFEGROUND:
2673 case mf168:
2674 case mf169:
2675 case mf170:
2676 case mf171:
2677 case mf172:
2678 case mf173:
2679 case mf174:
2680 case mf175:
2681 case mf176:
2682 case mf177:
2683 case mf178:
2684 case mf179:
2685 case mf180:
2686 case mf181:
2687 case mf182:
2688 case mf183:
2689 case mf184:
2690 case mf185:
2691 case mf186:
2692 case mf187:
2693 case mf188:
2694 case mf189:
2695 case mf190:
2696 case mf191:
2697 case mf192:
2698 case mf193:
2699 case mf194:
2700 case mf195:
2701 case mf196:
2702 case mf197:
2703 case mf198:
2704 case mf199:
2705 case mf200:
2706 case mf201:
2707 case mf202:
2708 case mf203:
2709 case mf204:
2710 case mf205:
2711 case mf206:
2712 case mf207:
2713 case mf208:
2714 case mf209:
2715 case mf210:
2716 case mf211:
2717 case mf212:
2718 case mf213:
2719 case mf214:
2720 case mf215:
2721 case mf216:
2722 case mf217:
2723 case mf218:
2724 case mf219:
2725 case mf220:
2726 case mf221:
2727 case mf222:
2728 case mf223:
2729 case mf224:
2730 case mf225:
2731 case mf226:
2732 case mf227:
2733 case mf228:
2734 case mf229:
2735 case mf230:
2736 case mf231:
2737 case mf232:
2738 case mf233:
2739 case mf234:
2740 case mf235:
2741 case mf236:
2742 case mf237:
2743 case mf238:
2744 case mf239:
2745 case mf240:
2746 case mf241:
2747 case mf242:
2748 case mf243:
2749 case mf244:
2750 case mf245:
2751 case mf246:
2752 case mf247:
2753 case mf248:
2754 case mf249:
2755 case mf250:
2756 case mf251:
2757 case mf252:
2758 case mf253:
2759 case mf254:
2760 case mfEXTENDED:
2761 5706470 break;
2762
2763 case mfPUSHUD:
2764 case mfPUSHLR:
2765 case mfPUSH4:
2766 case mfPUSHU:
2767 case mfPUSHD:
2768 case mfPUSHL:
2769 case mfPUSHR:
2770 case mfPUSHUDNS:
2771 case mfPUSHLRNS:
2772 case mfPUSH4NS:
2773 case mfPUSHUNS:
2774 case mfPUSHDNS:
2775 case mfPUSHLNS:
2776 case mfPUSHRNS:
2777 case mfPUSHUDINS:
2778 case mfPUSHLRINS:
2779 case mfPUSH4INS:
2780 case mfPUSHUINS:
2781 case mfPUSHDINS:
2782 case mfPUSHLINS:
2783 case mfPUSHRINS:
2784
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2785
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2786 {
2787 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2788 }
2789
2790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2791
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2792 {
2793
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2794 {
2795
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2796 {
2797 case cPUSH_HEAVY:
2798 case cPUSH_HW:
2799 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2800 72 tempitemx=x, tempitemy=y;
2801
2802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2803 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2804
2805 72 break;
2806
2807 case cPUSH_HEAVY2:
2808 case cPUSH_HW2:
2809 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2810 63 tempitemx=x, tempitemy=y;
2811
2812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2813 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2814
2815 63 break;
2816 }
2817 1032 }
2818 2438 }
2819
2820 3148 break;
2821
2822 case mfWHISTLE:
2823
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2824 {
2825 tempitem=getItemID(itemsbuf,itype_whistle,1);
2826
2827 if(tempitem<0) break;
2828
2829 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2830 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2831 {
2832 tempitemx=x;
2833 tempitemy=y;
2834 }
2835
2836 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2837 }
2838
2839 2418 break;
2840
2841 //Why is this here?
2842 case mfFAIRY:
2843 case mfMAGICFAIRY:
2844 case mfALLFAIRY:
2845 if(hints)
2846 {
2847 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2848
2849 if(tempitem < 0) break;
2850
2851 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2852 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2853 {
2854 tempitemx=x;
2855 tempitemy=y;
2856 }
2857
2858 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2859 }
2860
2861 break;
2862
2863 case mfANYFIRE:
2864
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2865 {
2866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2867 252 }
2868 else
2869 {
2870 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2871
2872
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2873
2874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2875
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2876 {
2877 189 tempitemx=x;
2878 189 tempitemy=y;
2879 189 }
2880
2881 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2882 }
2883
2884 504 break;
2885
2886 case mfSTRONGFIRE:
2887 if(!hints)
2888 {
2889 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2890 }
2891 else
2892 {
2893 tempitem=getItemID(itemsbuf,itype_candle,2);
2894
2895 if(tempitem<0) break;
2896
2897 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2898 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2899 {
2900 tempitemx=x;
2901 tempitemy=y;
2902 }
2903
2904 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2905 }
2906
2907 break;
2908
2909 case mfMAGICFIRE:
2910 if(!hints)
2911 {
2912 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2913 }
2914 else
2915 {
2916 tempitem=getItemID(itemsbuf,itype_wand,1);
2917
2918 if(tempitem<0) break;
2919
2920 tempweapon=wFire;
2921
2922 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2923 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2924 {
2925 tempitemx=x;
2926 tempitemy=y;
2927 }
2928 else
2929 {
2930 tempweaponx=x;
2931 tempweapony=y;
2932 }
2933
2934 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2935 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2936 }
2937
2938 break;
2939
2940 case mfDIVINEFIRE:
2941 if(!hints)
2942 {
2943 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2944 }
2945 else
2946 {
2947 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2948
2949 if(tempitem<0) break;
2950
2951 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2952 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2953 {
2954 tempitemx=x;
2955 tempitemy=y;
2956 }
2957
2958 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2959 }
2960
2961 break;
2962
2963 case mfARROW:
2964
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2965 {
2966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2967 732 }
2968 else
2969 {
2970 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2971
2972
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2973
2974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2975
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2976 {
2977 61 tempitemx=x;
2978 61 tempitemy=y;
2979 61 }
2980
2981 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2982 }
2983
2984 814 break;
2985
2986 case mfSARROW:
2987 if(!hints)
2988 {
2989 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2990 }
2991 else
2992 {
2993 tempitem=getItemID(itemsbuf,itype_arrow,2);
2994
2995 if(tempitem<0) break;
2996
2997 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2998 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2999 {
3000 tempitemx=x;
3001 tempitemy=y;
3002 }
3003
3004 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3005 }
3006
3007 break;
3008
3009 case mfGARROW:
3010 if(!hints)
3011 {
3012 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3013 }
3014 else
3015 {
3016 tempitem=getItemID(itemsbuf,itype_arrow,3);
3017
3018 if(tempitem<0) break;
3019
3020 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3021 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3022 {
3023 tempitemx=x;
3024 tempitemy=y;
3025 }
3026
3027 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3028 }
3029
3030 break;
3031
3032 case mfBOMB:
3033
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3034 {
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3036 16 }
3037 else
3038 {
3039 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3040 17 tempweapon = wLitBomb;
3041
3042 //if (tempitem<0) break;
3043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 12 tempweaponx=x;
3047 12 tempweapony=y;
3048 12 }
3049
3050 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3051 }
3052
3053 33 break;
3054
3055 case mfSBOMB:
3056
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3057 {
3058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3059 48 }
3060 else
3061 {
3062 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3063 //if (tempitem<0) break;
3064 48 tempweapon = wLitSBomb;
3065
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 36 tempweaponx=x;
3070 36 tempweapony=y;
3071 36 }
3072
3073 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3074 }
3075
3076 96 break;
3077
3078 case mfARMOS_SECRET:
3079
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3080 {
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3082 12 }
3083 24 break;
3084
3085 case mfBRANG:
3086
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3087 {
3088 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3089 }
3090 else
3091 {
3092 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3093
3094
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3095
3096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3097
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3098 {
3099 4 tempitemx=x;
3100 4 tempitemy=y;
3101 4 }
3102
3103 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3104 }
3105
3106 5 break;
3107
3108 case mfMBRANG:
3109 if(!hints)
3110 {
3111 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3112 }
3113 else
3114 {
3115 tempitem=getItemID(itemsbuf,itype_brang,2);
3116
3117 if(tempitem<0) break;
3118
3119 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3120 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3121 {
3122 tempitemx=x;
3123 tempitemy=y;
3124 }
3125
3126 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3127 }
3128
3129 break;
3130
3131 case mfFBRANG:
3132 if(!hints)
3133 {
3134 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3135 }
3136 else
3137 {
3138 tempitem=getItemID(itemsbuf,itype_brang,3);
3139
3140 if(tempitem<0) break;
3141
3142 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3143 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3144 {
3145 tempitemx=x;
3146 tempitemy=y;
3147 }
3148
3149 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3150 }
3151
3152 break;
3153
3154 case mfWANDMAGIC:
3155 if(!hints)
3156 {
3157 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3158 }
3159 else
3160 {
3161 tempitem=getItemID(itemsbuf,itype_wand,1);
3162
3163 if(tempitem<0) break;
3164
3165 tempweapon=itemsbuf[tempitem].wpn3;
3166
3167 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3168 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3169 {
3170 tempitemx=x;
3171 tempitemy=y;
3172 }
3173 else
3174 {
3175 tempweaponx=x;
3176 tempweapony=y;
3177 --lens_hint_weapon[wMagic][4];
3178
3179 if(lens_hint_weapon[wMagic][4]<-8)
3180 {
3181 lens_hint_weapon[wMagic][4]=8;
3182 }
3183 }
3184
3185 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3186 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3187 }
3188
3189 break;
3190
3191 case mfREFMAGIC:
3192
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3193 {
3194 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3195 }
3196 else
3197 {
3198 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3199
3200
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3201
3202 16 tempweapon=ewMagic;
3203
3204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3205
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3206 {
3207 13 tempitemx=x;
3208 13 tempitemy=y;
3209 13 }
3210 else
3211 {
3212 3 tempweaponx=x;
3213 3 tempweapony=y;
3214
3215
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3216 {
3217 1 --lens_hint_weapon[ewMagic][4];
3218 1 }
3219 else
3220 {
3221 2 ++lens_hint_weapon[ewMagic][4];
3222 }
3223
3224
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3225 {
3226 lens_hint_weapon[ewMagic][2]=up;
3227 }
3228
3229
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3230 {
3231 2 lens_hint_weapon[ewMagic][2]=down;
3232 2 }
3233 }
3234
3235 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3236 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3237 }
3238
3239 16 break;
3240
3241 case mfREFFIREBALL:
3242
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3243 {
3244 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3245 }
3246 else
3247 {
3248 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3249
3250
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3251
3252 16 tempweapon=ewFireball;
3253
3254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3255
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3256 {
3257 12 tempitemx=x;
3258 12 tempitemy=y;
3259 12 tempweaponx=x;
3260 12 tempweapony=y;
3261 12 ++lens_hint_weapon[ewFireball][3];
3262
3263
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3264 {
3265 1 lens_hint_weapon[ewFireball][3]=-8;
3266 1 lens_hint_weapon[ewFireball][4]=8;
3267 1 }
3268
3269
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3270 {
3271 8 ++lens_hint_weapon[ewFireball][4];
3272 8 }
3273 else
3274 {
3275 4 --lens_hint_weapon[ewFireball][4];
3276 }
3277 12 }
3278
3279 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3280 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3281 }
3282
3283 16 break;
3284
3285 case mfSWORD:
3286
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3287 {
3288 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3289 }
3290 else
3291 {
3292 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3293
3294
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3295
3296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3297
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3298 {
3299 5 tempitemx=x;
3300 5 tempitemy=y;
3301 5 }
3302
3303 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3304 }
3305
3306 7 break;
3307
3308 case mfWSWORD:
3309 if(!hints)
3310 {
3311 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3312 }
3313 else
3314 {
3315 tempitem=getItemID(itemsbuf,itype_sword,2);
3316
3317 if(tempitem<0) break;
3318
3319 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3320 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3321 {
3322 tempitemx=x;
3323 tempitemy=y;
3324 }
3325
3326 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3327 }
3328
3329 break;
3330
3331 case mfMSWORD:
3332 if(!hints)
3333 {
3334 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3335 }
3336 else
3337 {
3338 tempitem=getItemID(itemsbuf,itype_sword,3);
3339
3340 if(tempitem<0) break;
3341
3342 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3343 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3344 {
3345 tempitemx=x;
3346 tempitemy=y;
3347 }
3348
3349 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3350 }
3351
3352 break;
3353
3354 case mfXSWORD:
3355 if(!hints)
3356 {
3357 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3358 }
3359 else
3360 {
3361 tempitem=getItemID(itemsbuf,itype_sword,4);
3362
3363 if(tempitem<0) break;
3364
3365 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3366 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3367 {
3368 tempitemx=x;
3369 tempitemy=y;
3370 }
3371
3372 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3373 }
3374
3375 break;
3376
3377 case mfSWORDBEAM:
3378
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3379 {
3380 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3381 }
3382 else
3383 {
3384 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3385
3386
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3387
3388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3389
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3390 {
3391 11 tempitemx=x;
3392 11 tempitemy=y;
3393 11 }
3394
3395 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3396 }
3397
3398 16 break;
3399
3400 case mfWSWORDBEAM:
3401 if(!hints)
3402 {
3403 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3404 }
3405 else
3406 {
3407 tempitem=getItemID(itemsbuf,itype_sword,2);
3408
3409 if(tempitem<0) break;
3410
3411 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3412 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3413 {
3414 tempitemx=x;
3415 tempitemy=y;
3416 }
3417
3418 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3419 }
3420
3421 break;
3422
3423 case mfMSWORDBEAM:
3424 if(!hints)
3425 {
3426 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3427 }
3428 else
3429 {
3430 tempitem=getItemID(itemsbuf,itype_sword,3);
3431
3432 if(tempitem<0) break;
3433
3434 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3435 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3436 {
3437 tempitemx=x;
3438 tempitemy=y;
3439 }
3440
3441 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3442 }
3443
3444 break;
3445
3446 case mfXSWORDBEAM:
3447 if(!hints)
3448 {
3449 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3450 }
3451 else
3452 {
3453 tempitem=getItemID(itemsbuf,itype_sword,4);
3454
3455 if(tempitem<0) break;
3456
3457 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3458 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3459 {
3460 tempitemx=x;
3461 tempitemy=y;
3462 }
3463
3464 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3465 }
3466
3467 break;
3468
3469 case mfHOOKSHOT:
3470
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3471 {
3472 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3473 }
3474 else
3475 {
3476 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3477
3478
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3479
3480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3481
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3482 {
3483 12 tempitemx=x;
3484 12 tempitemy=y;
3485 12 }
3486
3487 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3488 }
3489
3490 17 break;
3491
3492 case mfWAND:
3493
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3494 {
3495 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3496 }
3497 else
3498 {
3499 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3500
3501
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3502
3503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3504
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3505 {
3506 28 tempitemx=x;
3507 28 tempitemy=y;
3508 28 }
3509
3510 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3511 }
3512
3513 35 break;
3514
3515 case mfHAMMER:
3516
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3517 {
3518 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3519 }
3520 else
3521 {
3522 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3523
3524
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3525
3526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3527
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3528 {
3529 13 tempitemx=x;
3530 13 tempitemy=y;
3531 13 }
3532
3533 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3534 }
3535
3536 17 break;
3537
3538 case mfARMOS_ITEM:
3539 case mfDIVE_ITEM:
3540
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3541 {
3542 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3543 2064 }
3544 2064 break;
3545
3546 case 16:
3547 case 17:
3548 case 18:
3549 case 19:
3550 case 20:
3551 case 21:
3552 case 22:
3553 case 23:
3554 case 24:
3555 case 25:
3556 case 26:
3557 case 27:
3558 case 28:
3559 case 29:
3560 case 30:
3561 case 31:
3562
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3564 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3565
3566 3618 break;
3567 case mfSECRETSNEXT:
3568 if(!hints)
3569 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3570 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3571
3572 break;
3573
3574 case mfSTRIKE:
3575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3576 {
3577 906 goto special;
3578 }
3579 else
3580 {
3581 break;
3582 }
3583
3584 28640 default: goto special;
3585
3586 special:
3587
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3588 {
3589
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3590 {
3591 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3592 4913 }
3593 6549 }
3594
3595 29546 break;
3596 }
3597 5748864 }
3598 2874432 }
3599
3600
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3601 {
3602
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3603 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3604
3605
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3606 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3607
3608
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3609 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3610
3611
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3612 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3613
3614
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3615 {
3616 43 showbombeddoor(dest, 0);
3617 43 }
3618
3619
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3620 {
3621 39 showbombeddoor(dest, 1);
3622 39 }
3623
3624
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3625 {
3626 showbombeddoor(dest, 2);
3627 }
3628
3629
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3630 {
3631 37 showbombeddoor(dest, 3);
3632 37 }
3633 8166 }
3634
3635
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3636 {
3637
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3638 {
3639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3640 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3641 1123 }
3642 else
3643 {
3644
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3645 {
3646 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3647 48 int32_t tempitemx=-16;
3648 48 int32_t tempitemy=-16;
3649
3650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3651
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3652 {
3653 24 tempitemx=tmpscr->stairx;
3654 24 tempitemy=tmpscr->stairy+playing_field_offset;
3655 24 }
3656
3657 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3658 48 }
3659 }
3660 2034 }
3661 }
3662 16332 }
3663
3664 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3665
3666 7997 void draw_lens_over()
3667 {
3668 // Oh, what the heck.
3669 static BITMAP *lens_scr = NULL;
3670 static int32_t last_width = -1;
3671 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3672
3673 // Only redraw the circle if the size has changed
3674
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3675 {
3676
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3677 {
3678 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3679 5 }
3680
3681 5 clear_to_color(lens_scr, BLACK);
3682 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3683 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3684 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3685 5 last_width=width;
3686 5 }
3687
3688 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3689 7997 }
3690
3691 //----------------------------------------------------------------
3692
3693 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3694 {
3695 //recreating a big bitmap every frame is highly sluggish.
3696
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3697 30701 clear_to_color(wavebuf, BLACK);
3698 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3699
3700 int32_t ofs;
3701 // int32_t amplitude=8;
3702 // int32_t wavelength=4;
3703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3704
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3705 30701 int32_t amp2=168;
3706
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3707 30701 int32_t i=frame%amp2;
3708
3709
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3710 {
3711
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3712 {
3713 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3714 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3715 }
3716 else
3717 {
3718 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3719 }
3720
3721
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3722 {
3723
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3724 {
3725 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3726 1320388608 }
3727 5157768 }
3728 5157768 }
3729 30701 }
3730
3731 3360 void draw_fuzzy(int32_t fuzz)
3732 // draws from right half of scrollbuf to framebuf
3733 {
3734 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3735 byte *start, *si, *di;
3736
3737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 if(fuzz<1)
3738 fuzz = 1;
3739
3740 3360 xstep = 128%fuzz;
3741
3742
2/2
✓ Branch 0 taken 700 times.
✓ Branch 1 taken 2660 times.
3360 if(xstep > 0)
3743 2660 xstep = fuzz-xstep;
3744
3745 3360 ystep = 112%fuzz;
3746
3747
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 2380 times.
3360 if(ystep > 0)
3748 2380 ystep = fuzz-ystep;
3749
3750 3360 firsty = 1;
3751
3752
2/2
✓ Branch 0 taken 3360 times.
✓ Branch 1 taken 121240 times.
124600 for(y=0; y<224;)
3753 {
3754 121240 start = &(scrollbuf->line[y][256]);
3755
3756
4/4
✓ Branch 0 taken 119560 times.
✓ Branch 1 taken 754320 times.
✓ Branch 2 taken 752640 times.
✓ Branch 3 taken 121240 times.
873880 for(dy=0; dy<ystep && dy+y<224; dy++)
3757 {
3758 752640 si = start;
3759 752640 di = &(framebuf->line[y+dy][0]);
3760 752640 i = xstep;
3761 752640 firstx = 1;
3762
3763
2/2
✓ Branch 0 taken 192675840 times.
✓ Branch 1 taken 752640 times.
193428480 for(dx=0; dx<256; dx++)
3764 {
3765 192675840 *(di++) = *si;
3766
3767
2/2
✓ Branch 0 taken 162350720 times.
✓ Branch 1 taken 30325120 times.
192675840 if(++i >= fuzz)
3768 {
3769
2/2
✓ Branch 0 taken 29572480 times.
✓ Branch 1 taken 752640 times.
30325120 if(!firstx)
3770 29572480 si += fuzz;
3771 else
3772 {
3773 752640 si += fuzz-xstep;
3774 752640 firstx = 0;
3775 }
3776
3777 30325120 i = 0;
3778 30325120 }
3779 192675840 }
3780 752640 }
3781
3782
2/2
✓ Branch 0 taken 117880 times.
✓ Branch 1 taken 3360 times.
121240 if(!firsty)
3783 117880 y += fuzz;
3784 else
3785 {
3786 3360 y += ystep;
3787 3360 ystep = fuzz;
3788 3360 firsty = 0;
3789 }
3790 }
3791 3360 }
3792
3793 8136917 void updatescr(bool allowwavy)
3794 {
3795
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 8136883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
8136917 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3796
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 8136883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
8136917 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3797
3798
2/2
✓ Branch 0 taken 8111213 times.
✓ Branch 1 taken 25704 times.
8136917 if(toogam)
3799 {
3800 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3801 25704 }
3802
3803
1/2
✓ Branch 0 taken 8136917 times.
✗ Branch 1 not taken.
8136917 if(Showpal)
3804 dump_pal(framebuf);
3805
3806
2/2
✓ Branch 0 taken 7954551 times.
✓ Branch 1 taken 182366 times.
8136917 if(!Playing)
3807 182366 black_opening_count=0;
3808
3809
2/2
✓ Branch 0 taken 8082665 times.
✓ Branch 1 taken 54252 times.
8136917 if(black_opening_count<0) //shape is opening up
3810 {
3811 54252 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3812
3813
2/4
✓ Branch 0 taken 54252 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54252 times.
54252 if(Advance||(!Paused))
3814 {
3815 54252 ++black_opening_count;
3816 54252 }
3817 54252 }
3818
2/2
✓ Branch 0 taken 8062073 times.
✓ Branch 1 taken 20592 times.
8082665 else if(black_opening_count>0) //shape is closing
3819 {
3820 20592 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3821
3822
2/4
✓ Branch 0 taken 20592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20592 times.
20592 if(Advance||(!Paused))
3823 {
3824 20592 --black_opening_count;
3825 20592 }
3826 20592 }
3827
3828
3/4
✓ Branch 0 taken 8063207 times.
✓ Branch 1 taken 73710 times.
✓ Branch 2 taken 8063207 times.
✗ Branch 3 not taken.
8136917 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3829 {
3830 black_opening_shape = bosCIRCLE;
3831 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3832 refreshTints();
3833 refreshpal=true;
3834 }
3835
3836
2/2
✓ Branch 0 taken 7891895 times.
✓ Branch 1 taken 245022 times.
8136917 if(refreshpal)
3837 {
3838 245022 refreshpal=false;
3839 245022 RAMpal[253] = _RGB(0,0,0);
3840 245022 RAMpal[254] = _RGB(63,63,63);
3841 245022 hw_palette = &RAMpal;
3842 245022 update_hw_pal = true;
3843
3844 245022 create_rgb_table(&rgb_table, RAMpal, NULL);
3845 245022 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3846 245022 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3847
3848
2/2
✓ Branch 0 taken 62725632 times.
✓ Branch 1 taken 245022 times.
62970654 for(int32_t q=0; q<PAL_SIZE; q++)
3849 {
3850 62725632 trans_table2.data[0][q] = q;
3851 62725632 trans_table2.data[q][q] = q;
3852 62725632 }
3853 245022 }
3854
3855 8136917 bool clearwavy = (wavy <= 0);
3856
3857
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 8129672 times.
8136917 if(wavy <= 0)
3858 {
3859 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3860 8129672 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3861 8129672 }
3862
3863 8136917 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3864
3865
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 8105966 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
8136917 if(wavy && Playing && allowwavy)
3866 {
3867 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3868 30701 }
3869
3870
2/2
✓ Branch 0 taken 8129672 times.
✓ Branch 1 taken 7245 times.
8136917 if(clearwavy)
3871 8129672 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3872
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3873 7245 wavy--; // Wavy was set by a script. Decrement it.
3874
3875
5/6
✓ Branch 0 taken 7954551 times.
✓ Branch 1 taken 182366 times.
✓ Branch 2 taken 184496 times.
✓ Branch 3 taken 7770055 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 184496 times.
8136917 if(Playing && msgpos && !screenscrolling)
3876 {
3877
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_bg_display_buf->clip))
3878 184496 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3879
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_portrait_display_buf->clip))
3880 184496 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3881
1/2
✓ Branch 0 taken 184496 times.
✗ Branch 1 not taken.
184496 if(!(msg_txt_display_buf->clip))
3882 184496 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3883 184496 }
3884
3885 /*
3886 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3887 {
3888 BITMAP* subBmp = 0;
3889 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3890 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3891 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3892 destroy_bitmap(subBmp);
3893 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3894 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3895 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3896 }
3897 */
3898
3899
2/2
✓ Branch 0 taken 8099400 times.
✓ Branch 1 taken 37517 times.
8136917 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3900
3901
2/2
✓ Branch 0 taken 8104025 times.
✓ Branch 1 taken 32892 times.
8136917 if(nosubscr)
3902 {
3903 32892 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3904 32892 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3905 32892 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3906 32892 }
3907
3908 //TODO: Optimize blit 'overcalls' -Gleeok
3909
2/2
✓ Branch 0 taken 32892 times.
✓ Branch 1 taken 8104025 times.
8136917 BITMAP *source = nosubscr ? panorama : wavybuf;
3910 8136917 blit(source,framebuf,0,0,0,0,256,224);
3911
3912 8136917 update_hw_screen();
3913 8136917 }
3914
3915 //----------------------------------------------------------------
3916
3917 PALETTE sys_pal;
3918
3919 int32_t onGUISnapshot()
3920 {
3921 char buf[200];
3922 int32_t num=0;
3923 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3924 do
3925 {
3926 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3927 }
3928 while(num<99999 && exists(buf));
3929
3930 BITMAP *b = create_bitmap_ex(8,resx,resy);
3931
3932 if(b)
3933 {
3934 if(MenuOpen)
3935 {
3936 //Cannot load game's palette while GUI elements are in focus. -Z
3937 //If there is a way to do this, then I have missed it.
3938 /*
3939 game_pal();
3940 RAMpal[253] = _RGB(0,0,0);
3941 RAMpal[254] = _RGB(63,63,63);
3942 zc_set_palette_range(RAMpal,0,255,false);
3943 memcpy(RAMpal, snappal, sizeof(snappal));
3944 create_rgb_table(&rgb_table, RAMpal, NULL);
3945 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3946 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3947
3948 for(int32_t q=0; q<PAL_SIZE; q++)
3949 {
3950 trans_table2.data[0][q] = q;
3951 trans_table2.data[q][q] = q;
3952 }
3953 */
3954 //ringcolor(false);
3955 //get_palette(RAMpal);
3956 blit(screen,b,0,0,0,0,resx,resy);
3957 //al_trace("Menu Open\n");
3958 //game_pal();
3959 //PALETTE temppal;
3960 //get_palette(temppal);
3961 //system_pal();
3962 save_bitmap(buf,b,sys_pal);
3963 //save_bitmap(buf,b,RAMpal);
3964 //save_bitmap(buf,b,snappal);
3965 }
3966 else
3967 {
3968 blit(screen,b,0,0,0,0,resx,resy);
3969 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3970 }
3971 destroy_bitmap(b);
3972 }
3973
3974 return D_O_K;
3975 }
3976
3977 int32_t onNonGUISnapshot()
3978 {
3979 PALETTE temppal;
3980 get_palette(temppal);
3981 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3982
3983 char buf[200];
3984 int32_t num=0;
3985
3986 do
3987 {
3988 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3989 }
3990 while(num<99999 && exists(buf));
3991
3992 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3993
3994 return D_O_K;
3995 }
3996
3997 int32_t onSnapshot()
3998 {
3999 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
4000 {
4001 onGUISnapshot();
4002 }
4003 else
4004 {
4005 onNonGUISnapshot();
4006 }
4007
4008 return D_O_K;
4009 }
4010
4011 int32_t onSaveMapPic()
4012 {
4013 int32_t mapres2 = 0;
4014 char buf[200];
4015 int32_t num=0;
4016 mapscr tmpscr_b[2];
4017 mapscr tmpscr_c[6];
4018 BITMAP* _screen_draw_buffer = NULL;
4019 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4020 set_clip_state(_screen_draw_buffer,1);
4021
4022 for(int32_t i=0; i<6; ++i)
4023 {
4024 tmpscr_c[i] = tmpscr2[i];
4025 tmpscr2[i].zero_memory();
4026
4027 if(i>=2)
4028 {
4029 continue;
4030 }
4031
4032 tmpscr_b[i] = tmpscr[i];
4033 tmpscr[i].zero_memory();
4034 }
4035
4036 do
4037 {
4038 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4039 }
4040 while(num<99999 && exists(buf));
4041
4042 BITMAP* mappic = NULL;
4043
4044
4045 bool done=false, redraw=true;
4046
4047 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4048
4049 if(!mappic)
4050 {
4051 system_pal();
4052 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4053 game_pal();
4054 return D_O_K;;
4055 }
4056
4057 // draw the map
4058 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4059
4060 for(int32_t y=0; y<8; y++)
4061 {
4062 for(int32_t x=0; x<16; x++)
4063 {
4064 if(!displayOnMap(x, y))
4065 {
4066 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4067 }
4068 else
4069 {
4070 int32_t s = (y<<4) + x;
4071 loadscr2(1,s,-1);
4072
4073 for(int32_t i=0; i<6; i++)
4074 {
4075 if(tmpscr[1].layermap[i]<=0)
4076 continue;
4077
4078 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4079 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4080 {
4081 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4082
4083 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4084 }
4085 }
4086
4087 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4088
4089 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4090
4091 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4092 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4093
4094 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4095
4096 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4097 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4098 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4099 {
4100 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4101 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4102 }
4103 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4104
4105 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4106
4107 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4108 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4109 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4110 {
4111 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4112 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4113 }
4114 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4115 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4116
4117 }
4118
4119 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4120 }
4121 }
4122
4123 for(int32_t i=0; i<6; ++i)
4124 {
4125 tmpscr2[i]=tmpscr_c[i];
4126
4127 if(i>=2)
4128 {
4129 continue;
4130 }
4131
4132 tmpscr[i]=tmpscr_b[i];
4133 }
4134
4135 save_bitmap(buf,mappic,RAMpal);
4136 destroy_bitmap(mappic);
4137 destroy_bitmap(_screen_draw_buffer);
4138 return D_O_K;
4139 }
4140
4141 /*
4142 int32_t onSaveMapPic()
4143 {
4144 BITMAP* mappic = NULL;
4145 BITMAP* _screen_draw_buffer = NULL;
4146 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4147 int32_t mapres2 = 0;
4148 char buf[20];
4149 int32_t num=0;
4150 set_clip_state(_screen_draw_buffer,1);
4151 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4152
4153 do
4154 {
4155 sprintf(buf, "zelda%03d.png", ++num);
4156 }
4157 while(num<999 && exists(buf));
4158
4159 // if(!mappic) {
4160 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4161
4162 if(!mappic)
4163 {
4164 system_pal();
4165 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4166 game_pal();
4167 return D_O_K;
4168 }
4169
4170 // }
4171
4172 int32_t layermap, layerscreen;
4173 int32_t x2=0;
4174
4175 // draw the map
4176 for(int32_t y=0; y<8; y++)
4177 {
4178 for(int32_t x=0; x<16; x++)
4179 {
4180 int32_t s = (y<<4) + x;
4181
4182 if(!displayOnMap(x, y))
4183 {
4184 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4185 }
4186 else
4187 {
4188 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4189 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4190
4191 for(int32_t k=0; k<4; k++)
4192 {
4193 if(k==2)
4194 {
4195 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4196 }
4197
4198 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4199
4200 if(layermap>-1)
4201 {
4202 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4203
4204 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4205 {
4206 for(int32_t i=0; i<176; i++)
4207 {
4208 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4209 }
4210 }
4211 else
4212 {
4213 for(int32_t i=0; i<176; i++)
4214 {
4215 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4216 }
4217 }
4218 }
4219 }
4220
4221 for(int32_t i=0; i<176; i++)
4222 {
4223 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4224 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4225 {
4226 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4227 }
4228 }
4229
4230 for(int32_t k=4; k<6; k++)
4231 {
4232 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4233
4234 if(layermap>-1)
4235 {
4236 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4237
4238 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4239 {
4240 for(int32_t i=0; i<176; i++)
4241 {
4242 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4243 }
4244 }
4245 else
4246 {
4247 for(int32_t i=0; i<176; i++)
4248 {
4249 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4250 }
4251 }
4252 }
4253 }
4254 }
4255
4256 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4257 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4258 }
4259
4260 }
4261
4262 save_bitmap(buf,mappic,RAMpal);
4263 destroy_bitmap(mappic);
4264 destroy_bitmap(_screen_draw_buffer);
4265 return D_O_K;
4266 }
4267 */
4268
4269 14 void f_Quit(int32_t type)
4270 {
4271
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4272 return;
4273
4274 14 bool from_menu = is_sys_pal;
4275
4276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4277 {
4278 14 music_pause();
4279 14 pause_all_sfx();
4280 14 sys_mouse();
4281 14 }
4282 14 enter_sys_pal();
4283 14 clear_keybuf();
4284
4285
3/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 13 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4286 13 replay_poll();
4287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4288 14 replay_peek_quit();
4289
4290
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4291 switch(type)
4292 {
4293 case qQUIT:
4294 onQuit();
4295 break;
4296
4297 case qRESET:
4298 onReset();
4299 break;
4300
4301 case qEXIT:
4302 onExit();
4303 break;
4304 }
4305
4306
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4307 {
4308 14 kill_sfx();
4309 14 music_stop();
4310 14 exit_sys_pal();
4311 14 update_hw_screen();
4312 14 }
4313 else
4314 {
4315 exit_sys_pal();
4316 if(!from_menu)
4317 {
4318 music_resume();
4319 resume_all_sfx();
4320 }
4321 }
4322
4323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4324 14 game_mouse();
4325 14 eat_buttons();
4326
4327 14 zc_readrawkey(KEY_ESC);
4328
4329 14 zc_readrawkey(KEY_ENTER);
4330 14 }
4331
4332 //----------------------------------------------------------------
4333
4334 int32_t onNoWalls()
4335 {
4336 cheats_enqueue(Cheat::Walls);
4337 return D_O_K;
4338 }
4339
4340 int32_t onIgnoreSideview()
4341 {
4342 cheats_enqueue(Cheat::IgnoreSideView);
4343 return D_O_K;
4344 }
4345
4346 8136832 int32_t input_idle(bool checkmouse)
4347 {
4348 static int32_t mx, my, mz, mb;
4349
4350
4/6
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2139285 times.
✓ Branch 3 taken 5997547 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2139285 times.
10276117 if(keypressed() || zc_key_pressed() ||
4351
4/8
✓ Branch 0 taken 2139285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2139285 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2139285 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2139285 times.
✗ Branch 7 not taken.
2139285 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4352 {
4353 5997547 idle_count = 0;
4354
4355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5997547 times.
5997547 if(active_count < MAX_ACTIVE)
4356 {
4357 5997547 ++active_count;
4358 5997547 }
4359 5997547 }
4360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2139285 times.
2139285 else if(idle_count < MAX_IDLE)
4361 {
4362 2139285 ++idle_count;
4363 2139285 active_count = 0;
4364 2139285 }
4365
4366 8136832 mx = mouse_x;
4367 8136832 my = mouse_y;
4368 8136832 mz = mouse_z;
4369 8136832 mb = mouse_b;
4370
4371 8136832 return idle_count;
4372 }
4373
4374 int32_t onGoFast()
4375 {
4376 cheats_enqueue(Cheat::Fast);
4377 return D_O_K;
4378 }
4379
4380 int32_t onKillCheat()
4381 {
4382 cheats_enqueue(Cheat::Kill);
4383 return D_O_K;
4384 }
4385
4386 int32_t onSecretsCheat()
4387 {
4388 cheats_enqueue(Cheat::TrigSecrets);
4389 return D_O_K;
4390 }
4391 int32_t onSecretsCheatPerm()
4392 {
4393 cheats_enqueue(Cheat::TrigSecretsPerm);
4394 return D_O_K;
4395 }
4396
4397 int32_t onShowLayer0()
4398 {
4399 show_layer_0 = !show_layer_0;
4400 return D_O_K;
4401 }
4402 int32_t onShowLayer1()
4403 {
4404 show_layer_1 = !show_layer_1;
4405 return D_O_K;
4406 }
4407 int32_t onShowLayer2()
4408 {
4409 show_layer_2 = !show_layer_2;
4410 return D_O_K;
4411 }
4412 int32_t onShowLayer3()
4413 {
4414 show_layer_3 = !show_layer_3;
4415 return D_O_K;
4416 }
4417 int32_t onShowLayer4()
4418 {
4419 show_layer_4 = !show_layer_4;
4420 return D_O_K;
4421 }
4422 int32_t onShowLayer5()
4423 {
4424 show_layer_5 = !show_layer_5;
4425 return D_O_K;
4426 }
4427 int32_t onShowLayer6()
4428 {
4429 show_layer_6 = !show_layer_6;
4430 return D_O_K;
4431 }
4432 int32_t onShowLayerO()
4433 {
4434 show_layer_over=!show_layer_over;
4435 return D_O_K;
4436 }
4437 int32_t onShowLayerP()
4438 {
4439 show_layer_push=!show_layer_push;
4440 return D_O_K;
4441 }
4442 int32_t onShowLayerS()
4443 {
4444 show_sprites=!show_sprites;
4445 return D_O_K;
4446 }
4447 int32_t onShowLayerF()
4448 {
4449 show_ffcs=!show_ffcs;
4450 return D_O_K;
4451 }
4452 int32_t onShowLayerW()
4453 {
4454 show_walkflags=!show_walkflags;
4455 if(show_walkflags)
4456 show_effectflags = false;
4457 return D_O_K;
4458 }
4459 int32_t onShowLayerE()
4460 {
4461 show_effectflags=!show_effectflags;
4462 if(show_effectflags)
4463 show_walkflags = false;
4464 return D_O_K;
4465 }
4466 int32_t onShowFFScripts()
4467 {
4468 show_ff_scripts=!show_ff_scripts;
4469 return D_O_K;
4470 }
4471 int32_t onShowHitboxes()
4472 {
4473 show_hitboxes=!show_hitboxes;
4474 return D_O_K;
4475 }
4476 int32_t onShowInfoOpacity()
4477 {
4478 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4479 zc_set_config("zc","debug_info_opacity",info_opacity);
4480 return D_O_K;
4481 }
4482
4483 int32_t onLightSwitch()
4484 {
4485 cheats_enqueue(Cheat::Light);
4486 return D_O_K;
4487 }
4488
4489 int32_t onGoTo();
4490 int32_t onGoToComplete();
4491
4492 8136832 void syskeys()
4493 {
4494 8136832 update_system_keys();
4495
4496 int32_t oldtitle_version;
4497
4498
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(close_button_quit)
4499 {
4500 close_button_quit=false;
4501 f_Quit(qEXIT);
4502 }
4503
4504 8136832 poll_joystick();
4505
4506
2/10
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8136832 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8136832 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4507 {
4508 oldtitle_version=title_version;
4509 System();
4510 }
4511
4512 8136832 mouse_down=gui_mouse_b();
4513
4514
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(zc_read_system_key(KEY_F1))
4515 {
4516 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4517 {
4518 halt=!halt;
4519 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4520 }
4521 else
4522 {
4523 Throttlefps=!Throttlefps;
4524 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4525 logic_counter=0;
4526 }
4527 }
4528
4529 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4530 /*
4531 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4532 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4533 */
4534
4535
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(zc_read_system_key(KEY_F2))
4536 {
4537 ShowFPS=!ShowFPS;
4538 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4539 }
4540
4541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8136832 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4542
4543
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8136832 if(zc_read_system_key(KEY_F4) && Playing)
4544 {
4545 Paused=true;
4546 Advance=true;
4547 }
4548
4549
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(zc_read_system_key(KEY_F6)) onTryQuit();
4550
4551 #ifndef ALLEGRO_MACOSX
4552
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4553
4554
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4555 #else
4556 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4557
4558 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4559 #endif
4560
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8136832 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4561
4562
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if (zc_read_system_key(KEY_F12))
4563 {
4564 onSnapshot();
4565 }
4566
4567
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8136832 if(debug_enabled && zc_read_system_key(KEY_TAB))
4568 set_debug(!get_debug());
4569
4570
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(CheatModifierKeys())
4571 {
4572 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4573 {
4574 if(!bindable_cheat(c))
4575 continue;
4576 if(get_debug() || cheat >= cheat_lvl(c))
4577 {
4578 if(checkcheat(c))
4579 cheats_hit_bind(c);
4580 }
4581 }
4582 }
4583
4584
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(volkeys)
4585 {
4586 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4587
4588 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4589
4590 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4591
4592 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4593 }
4594
4595
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8136832 if(!get_debug() || !SystemKeys || replay_is_replaying())
4596 8136832 goto bottom;
4597
4598 if(zc_readkey(KEY_D))
4599 {
4600 details = !details;
4601 rectfill(screen,0,0,319,7,BLACK);
4602 rectfill(screen,0,8,31,239,BLACK);
4603 rectfill(screen,288,8,319,239,BLACK);
4604 rectfill(screen,32,232,287,239,BLACK);
4605 }
4606
4607 if(zc_readkey(KEY_P)) Paused=!Paused;
4608
4609 //if(zc_readkey(KEY_P)) centerHero();
4610 if(zc_readkey(KEY_A))
4611 {
4612 Paused=true;
4613 Advance=true;
4614 }
4615
4616 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4617 #ifndef ALLEGRO_MACOSX
4618 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4619
4620 if(zc_readkey(KEY_F7))
4621 {
4622 Matrix(ss_speed, ss_density, 0);
4623 game_pal();
4624 }
4625 #else
4626 // The reason these are different on Mac in the first place is that
4627 // the OS doesn't let us use F9 and F10...
4628 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4629
4630 if(zc_readkey(KEY_F9))
4631 {
4632 Matrix(ss_speed, ss_density, 0);
4633 game_pal();
4634 }
4635 #endif
4636 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4637 {
4638 //change containers
4639 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4640 {
4641 //magic containers
4642 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4643 {
4644 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4645 }
4646 else
4647 {
4648 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4649 }
4650 }
4651 else
4652 {
4653 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4654 {
4655 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4656 }
4657 else
4658 {
4659 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4660 }
4661 }
4662 }
4663
4664 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4665 {
4666 //change containers
4667 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4668 {
4669 //magic containers
4670 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4671 {
4672 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4673 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4674 //heart containers
4675 }
4676 else
4677 {
4678 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4679 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4680 }
4681 }
4682 else
4683 {
4684 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4685 {
4686 game->set_magic(zc_max(game->get_magic()-1,0));
4687 }
4688 else
4689 {
4690 game->set_life(zc_max(game->get_life()-1,0));
4691 }
4692 }
4693 }
4694
4695 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4696
4697 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4698
4699 verifyBothWeapons();
4700
4701 bottom:
4702
4703
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(input_idle(true) > after_time())
4704 {
4705 Matrix(ss_speed, ss_density, 0);
4706 game_pal();
4707 }
4708 8136832 }
4709
4710 425791 void checkQuitKeys()
4711 {
4712 #ifndef ALLEGRO_MACOSX
4713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425791 times.
425791 if(key[KEY_F9]) f_Quit(qRESET);
4714
4715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425791 times.
425791 if(key[KEY_F10]) f_Quit(qEXIT);
4716 #else
4717 if(key[KEY_F7]) f_Quit(qRESET);
4718
4719 if(key[KEY_F8]) f_Quit(qEXIT);
4720 #endif
4721 425791 }
4722
4723 8136832 bool CheatModifierKeys()
4724 {
4725 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4726 // to trigger cheats.
4727
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if (replay_is_replaying())
4728 8136832 return false;
4729
4730 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4731 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4732 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4733 {
4734 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4735 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4736 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4737 {
4738 return true;
4739 }
4740 }
4741 return false;
4742 8136832 }
4743
4744 //99:05:54, for some reason?
4745 #define OLDMAXTIME 21405240
4746 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4747 #define MAXTIME 1944000000
4748
4749 8136917 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4750 {
4751
2/2
✓ Branch 0 taken 7843332 times.
✓ Branch 1 taken 293585 times.
8136917 if(zcmusic!=NULL)
4752 {
4753 293585 zcmusic_poll();
4754 293585 }
4755
4756 8136917 updatescr(allowwavy);
4757
4758 8136917 Advance=false;
4759
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8136917 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8136917 times.
8136917 while(Paused && !Advance && !Quit)
4760 {
4761 // have to call this, otherwise we'll get an infinite loop
4762 syskeys();
4763 if(allowF6Script)
4764 {
4765 FFCore.runF6Engine();
4766 }
4767 throttleFPS();
4768
4769 #ifdef _WIN32
4770
4771 if(use_dwm_flush)
4772 {
4773 do_DwmFlush();
4774 }
4775
4776 #endif
4777
4778 // to keep music playing
4779 if(zcmusic!=NULL)
4780 {
4781 zcmusic_poll();
4782 }
4783
4784 update_hw_screen();
4785 }
4786
4787
2/2
✓ Branch 0 taken 8136844 times.
✓ Branch 1 taken 73 times.
8136917 if(Quit)
4788 73 return;
4789
4790
3/4
✓ Branch 0 taken 7954542 times.
✓ Branch 1 taken 182302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7954542 times.
8136844 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4791 7954542 game->change_time(1);
4792
4793
3/4
✓ Branch 0 taken 8136844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1532697 times.
✓ Branch 3 taken 6604147 times.
8136844 if (!replay_is_active() || replay_get_version() >= 11)
4794
2/2
✓ Branch 0 taken 27588546 times.
✓ Branch 1 taken 1532697 times.
29121243 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4795 29121243 down_control_states[i] = raw_control_state[i];
4796
4797
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8136852 times.
8136844 if (replay_is_active())
4798 {
4799
2/2
✓ Branch 0 taken 1270471 times.
✓ Branch 1 taken 6866381 times.
8136852 if (replay_get_version() >= 3)
4800 6866381 replay_poll();
4801
4802
6/6
✓ Branch 0 taken 6604137 times.
✓ Branch 1 taken 1532695 times.
✓ Branch 2 taken 3183485 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 3082950 times.
8136852 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4803 1633230 replay_peek_input();
4804 8136832 }
4805
4806 8136844 load_control_called_this_frame = false;
4807
4808 8136844 poll_keyboard();
4809 8136844 update_keys();
4810
4811 8136844 ++frame;
4812
4813
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8136832 times.
8136844 if (replay_is_replaying())
4814 8136832 replay_do_cheats();
4815 8136844 syskeys();
4816
4817 // The mouse variables can change from the mouse thread at anytime during a frame,
4818 // so save the result at the start so that replaying is consistent.
4819 8136844 script_mouse_x = gui_mouse_x();
4820 8136844 script_mouse_y = gui_mouse_y();
4821 8136844 script_mouse_z = mouse_z;
4822 8136844 script_mouse_b = mouse_b;
4823
4824 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4825 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4826 // approach here means it doesn't matter which call adds the cheat.
4827 8136844 cheats_execute_queued();
4828
4829
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8136832 times.
8136844 if (replay_is_replaying())
4830 8136832 replay_peek_quit();
4831
2/2
✓ Branch 0 taken 8136830 times.
✓ Branch 1 taken 14 times.
8136844 if (GameFlags & GAMEFLAG_TRYQUIT)
4832 14 replay_step_quit(0);
4833
2/2
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 8133912 times.
8136844 if(allowF6Script)
4834 8133912 FFCore.runF6Engine();
4835
2/2
✓ Branch 0 taken 8136619 times.
✓ Branch 1 taken 225 times.
8136844 if (Quit)
4836 225 replay_step_quit(Quit);
4837 // Someday... maybe install a Turbo button here?
4838 8136844 throttleFPS();
4839
4840 #ifdef _WIN32
4841
4842 if(use_dwm_flush)
4843 {
4844 do_DwmFlush();
4845 }
4846
4847 #endif
4848
4849 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4850
2/2
✓ Branch 0 taken 46694 times.
✓ Branch 1 taken 8090150 times.
8136844 if(sfxcleanup)
4851 8090150 sfx_cleanup();
4852 8136917 }
4853
4854 70 void zapout()
4855 {
4856 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4857 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4858
4859 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4860 70 script_drawing_commands.Clear();
4861
4862 // zap out
4863
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=1; i<=24; i++)
4864 {
4865 1680 draw_fuzzy(i);
4866 1680 advanceframe(true);
4867
4868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4869 {
4870 break;
4871 }
4872 1680 }
4873 70 }
4874
4875 70 void zapin()
4876 {
4877 70 FFCore.warpScriptCheck();
4878 70 draw_screen(tmpscr);
4879 70 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4880 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4881 70 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4882
4883 // zap out
4884 70 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4885
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1680 times.
1750 for(int32_t i=24; i>=1; i--)
4886 {
4887 1680 draw_fuzzy(i);
4888 1680 advanceframe(true);
4889
4890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(Quit)
4891 {
4892 break;
4893 }
4894 1680 }
4895 70 }
4896
4897
4898 38 void wavyout(bool showhero)
4899 {
4900 38 draw_screen(tmpscr, showhero);
4901 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4902
4903 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4904 38 clear_to_color(wavebuf,0);
4905 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4906
4907 static PALETTE wavepal;
4908
4909 int32_t ofs;
4910 38 int32_t amplitude=8;
4911
4912 38 int32_t wavelength=4;
4913 38 double palpos=0, palstep=4, palstop=126;
4914
4915 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4916
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4917 {
4918
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4919 {
4920 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4921 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4922 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4923 408576 }
4924
4925 1596 palpos+=palstep;
4926
4927
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
4928 {
4929 1596 hw_palette = &wavepal;
4930 1596 update_hw_pal = true;
4931 1596 }
4932 else
4933 {
4934 hw_palette = &RAMpal;
4935 update_hw_pal = true;
4936 }
4937
4938
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
4939 {
4940
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
4941 {
4942 68640768 ofs=0;
4943
4944
4/4
✓ Branch 0 taken 33503232 times.
✓ Branch 1 taken 35137536 times.
✓ Branch 2 taken 16751616 times.
✓ Branch 3 taken 16751616 times.
68640768 if((j<i)&&(j&1))
4945 {
4946 16751616 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4947 16751616 }
4948
4949 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4950 68640768 }
4951 268128 }
4952
4953 1596 advanceframe(true);
4954
4955 // animate_combos();
4956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
4957 break;
4958 1596 }
4959
4960 38 destroy_bitmap(wavebuf);
4961 38 }
4962
4963 38 void wavyin()
4964 {
4965 38 draw_screen(tmpscr);
4966 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4967
4968 38 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4969 38 clear_to_color(wavebuf,0);
4970 38 blit(framebuf,wavebuf,0,0,16,0,256,224);
4971
4972 static PALETTE wavepal;
4973
4974 //Breaks dark rooms.
4975 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4976 /*
4977 loadfullpal();
4978 loadlvlpal(DMaps[currdmap].color);
4979 ringcolor(false);
4980 */
4981 38 refreshpal=false;
4982 int32_t ofs;
4983 38 int32_t amplitude=8;
4984 38 int32_t wavelength=4;
4985 38 double palpos=168, palstep=4, palstop=126;
4986
4987 38 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4988
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 1596 times.
1634 for(int32_t i=0; i<168; i+=wavelength)
4989 {
4990
2/2
✓ Branch 0 taken 408576 times.
✓ Branch 1 taken 1596 times.
410172 for(int32_t l=0; l<256; l++)
4991 {
4992 408576 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4993 408576 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4994 408576 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4995 408576 }
4996
4997 1596 palpos-=palstep;
4998
4999
1/2
✓ Branch 0 taken 1596 times.
✗ Branch 1 not taken.
1596 if(palpos>=0)
5000 {
5001 1596 hw_palette = &wavepal;
5002 1596 update_hw_pal = true;
5003 1596 }
5004 else
5005 {
5006 hw_palette = &RAMpal;
5007 update_hw_pal = true;
5008 }
5009
5010
2/2
✓ Branch 0 taken 268128 times.
✓ Branch 1 taken 1596 times.
269724 for(int32_t j=0; j+playing_field_offset<224; j++)
5011 {
5012
2/2
✓ Branch 0 taken 68640768 times.
✓ Branch 1 taken 268128 times.
68908896 for(int32_t k=0; k<256; k++)
5013 {
5014 68640768 ofs=0;
5015
5016
4/4
✓ Branch 0 taken 34728960 times.
✓ Branch 1 taken 33911808 times.
✓ Branch 2 taken 17568768 times.
✓ Branch 3 taken 17160192 times.
68640768 if((j<(167-i))&&(j&1))
5017 {
5018 17160192 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5019 17160192 }
5020
5021 68640768 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5022 68640768 }
5023 268128 }
5024
5025 1596 advanceframe(true);
5026 // animate_combos();
5027
5028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1596 times.
1596 if(Quit)
5029 break;
5030 1596 }
5031
5032 38 destroy_bitmap(wavebuf);
5033 38 }
5034
5035 1922 void blackscr(int32_t fcnt,bool showsubscr)
5036 {
5037 1922 reset_pal_cycling();
5038 1922 script_drawing_commands.Clear();
5039
5040 1922 FFCore.warpScriptCheck();
5041 1922 bool showtime = game->should_show_time();
5042
2/2
✓ Branch 0 taken 1922 times.
✓ Branch 1 taken 57590 times.
59512 while(fcnt>0)
5043 {
5044 57590 clear_bitmap(framebuf);
5045
5046
2/2
✓ Branch 0 taken 19740 times.
✓ Branch 1 taken 37850 times.
57590 if(showsubscr)
5047 {
5048 37850 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5049
3/4
✓ Branch 0 taken 37850 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 37100 times.
37850 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5050 {
5051 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5052 750 }
5053 37850 }
5054
5055 57590 advanceframe(true);
5056
5057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57590 times.
57590 if(Quit)
5058 break;
5059
5060 57590 --fcnt;
5061 }
5062 1922 }
5063
5064 726 void openscreen(int32_t shape)
5065 {
5066 726 reset_pal_cycling();
5067 726 black_opening_count=0;
5068
5069
3/4
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
726 if(COOLSCROLL || shape>-1)
5070 {
5071 627 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5072 627 return;
5073 }
5074 else
5075 {
5076 99 Hero.setDontDraw(true);
5077 99 show_subscreen_dmap_dots=false;
5078 99 show_subscreen_numbers=false;
5079 // show_subscreen_items=false;
5080 99 show_subscreen_life=false;
5081 }
5082
5083 99 int32_t x=128;
5084
5085 99 FFCore.warpScriptCheck();
5086
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 7920 times.
8019 for(int32_t i=0; i<80; i++)
5087 {
5088 7920 draw_screen(tmpscr);
5089 //? draw_screen already draws the subscreen -DD
5090 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5091 7920 x=128-(((i*128/80)/8)*8);
5092
5093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(x>0)
5094 {
5095 7920 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5096 7920 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5097 7920 }
5098
5099 7920 advanceframe(true);
5100
5101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7920 times.
7920 if(Quit)
5102 {
5103 break;
5104 }
5105 7920 }
5106
5107 99 Hero.setDontDraw(false);
5108 99 show_subscreen_items=true;
5109 99 show_subscreen_dmap_dots=true;
5110 726 }
5111
5112 void closescreen(int32_t shape)
5113 {
5114 reset_pal_cycling();
5115 black_opening_count=0;
5116
5117 if(COOLSCROLL || shape>-1)
5118 {
5119 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5120 return;
5121 }
5122 else
5123 {
5124 Hero.setDontDraw(true);
5125 show_subscreen_dmap_dots=false;
5126 show_subscreen_numbers=false;
5127 // show_subscreen_items=false;
5128 show_subscreen_life=false;
5129 }
5130
5131 int32_t x=128;
5132
5133 FFCore.warpScriptCheck();
5134 for(int32_t i=79; i>=0; --i)
5135 {
5136 draw_screen(tmpscr);
5137 //? draw_screen already draws the subscreen -DD
5138 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5139 x=128-(((i*128/80)/8)*8);
5140
5141 if(x>0)
5142 {
5143 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5144 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5145 }
5146
5147 advanceframe(true);
5148
5149 if(Quit)
5150 {
5151 break;
5152 }
5153 }
5154
5155 Hero.setDontDraw(false);
5156 show_subscreen_items=true;
5157 show_subscreen_dmap_dots=true;
5158 }
5159
5160 179 int32_t TriforceCount()
5161 {
5162 179 int32_t c=0;
5163
5164
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5165
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5166 1044 ++c;
5167
5168 179 return c;
5169 }
5170
5171 int32_t onCustomGame()
5172 {
5173 int32_t file = getsaveslot();
5174
5175 if(file < 0)
5176 return D_O_K;
5177
5178 bool ret = (custom_game(file)!=0);
5179 return ret ? D_CLOSE : D_O_K;
5180 }
5181
5182 int32_t onContinue()
5183 {
5184 return D_CLOSE;
5185 }
5186
5187 int32_t onEsc() // Unused?? -L
5188 {
5189 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5190 }
5191
5192 int32_t onVsync()
5193 {
5194 Throttlefps = !Throttlefps;
5195 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5196 return D_O_K;
5197 }
5198
5199 int32_t onWinPosSave()
5200 {
5201 SaveWinPos = !SaveWinPos;
5202 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5203 return D_O_K;
5204 }
5205 int32_t onIntegerScaling()
5206 {
5207 scaleForceInteger = !scaleForceInteger;
5208 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5209 return D_O_K;
5210 }
5211 int32_t onStretchGame()
5212 {
5213 stretchGame = !stretchGame;
5214 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5215 return D_O_K;
5216 }
5217
5218 int32_t onClickToFreeze()
5219 {
5220 ClickToFreeze = !ClickToFreeze;
5221 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5222 return D_O_K;
5223 }
5224
5225 int32_t OnSaveZCConfig()
5226 {
5227 if(jwin_alert3(
5228 "Save Configuration",
5229 "Are you sure that you wish to save your present configuration settings?",
5230 "This will overwrite your prior settings!",
5231 NULL,
5232 "&Yes",
5233 "&No",
5234 NULL,
5235 'y',
5236 'n',
5237 0,
5238 get_zc_font(font_lfont)) == 1)
5239 {
5240 save_game_configs();
5241 return D_O_K;
5242 }
5243 else return D_O_K;
5244 }
5245
5246 int32_t OnnClearQuestDir()
5247 {
5248 if(jwin_alert3(
5249 "Clear Current Directory Cache",
5250 "Are you sure that you wish to clear the current cached directory?",
5251 "This will default the current directory to the ROOT for this instance of ZC Player!",
5252 NULL,
5253 "&Yes",
5254 "&No",
5255 NULL,
5256 'y',
5257 'n',
5258 0,
5259 get_zc_font(font_lfont)) == 1)
5260 {
5261 zc_set_config("zeldadx","win_qst_dir","");
5262 flush_config_file();
5263 strcpy(qstdir,"");
5264 #ifdef __EMSCRIPTEN__
5265 em_sync_fs();
5266 #endif
5267 return D_O_K;
5268 }
5269 else return D_O_K;
5270 }
5271
5272
5273 int32_t onConsoleZASM()
5274 {
5275 if ( !zasm_debugger )
5276 {
5277 AlertDialog("WARNING: ZASM Debugger",
5278 "Enabling this will open the ZASM Debugger Console"
5279 "\nThis will likely grind ZC to a halt with lag."
5280 "\nTo make any use of this, it is suggested that you read"
5281 "\nthe documentation for 'void Breakpoint(char[] string);'"
5282 " in 'ZScript_Additions.txt'"
5283 "\nThis is not recommended for normal users,"
5284 " and is only intended for ZC developers,"
5285 "\nor quest developers coding directly in ZASM"
5286 "\nAre you sure that you wish to open the ZASM Debugger?",
5287 [&](bool ret,bool)
5288 {
5289 if(ret)
5290 {
5291 FFCore.ZASMPrint(true);
5292 }
5293 }).show();
5294 return D_O_K;
5295 }
5296 else
5297 {
5298 FFCore.ZASMPrint(false);
5299 return D_O_K;
5300 }
5301 }
5302
5303
5304 int32_t onConsoleZScript()
5305 {
5306 if ( !zscript_debugger )
5307 {
5308 AlertDialog("ZScript Debugger",
5309 "Enabling this will open the ZScript Debugger Console"
5310 "\nThis will display any messages logged by scripts,"
5311 " including script errors."
5312 "\nAre you sure that you wish to open the ZScript Debugger?",
5313 [&](bool ret,bool)
5314 {
5315 if(ret)
5316 {
5317 FFCore.ZScriptConsole(true);
5318 }
5319 }).show();
5320 return D_O_K;
5321 }
5322 else
5323 {
5324 FFCore.ZScriptConsole(false);
5325 return D_O_K;
5326 }
5327 }
5328
5329 int32_t onClrConsoleOnReload()
5330 {
5331 clearConsoleOnReload = !clearConsoleOnReload;
5332 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5333 return D_O_K;
5334 }
5335 int32_t onClrConsoleOnLoad()
5336 {
5337 clearConsoleOnLoad = !clearConsoleOnLoad;
5338 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5339 return D_O_K;
5340 }
5341
5342
5343 int32_t onFrameSkip()
5344 {
5345 FrameSkip = !FrameSkip;
5346 return D_O_K;
5347 }
5348
5349 int32_t onSaveDragResize()
5350 {
5351 SaveDragResize = !SaveDragResize;
5352 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5353 return D_O_K;
5354 }
5355
5356 int32_t onDragAspect()
5357 {
5358 DragAspect = !DragAspect;
5359 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5360 return D_O_K;
5361 }
5362
5363 int32_t onTransLayers()
5364 {
5365 TransLayers = !TransLayers;
5366 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5367 return D_O_K;
5368 }
5369
5370 int32_t onNESquit()
5371 {
5372 NESquit = !NESquit;
5373 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5374 return D_O_K;
5375 }
5376
5377 int32_t onVolKeys()
5378 {
5379 volkeys = !volkeys;
5380 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5381 return D_O_K;
5382 }
5383
5384 int32_t onShowFPS()
5385 {
5386 ShowFPS = !ShowFPS;
5387 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5388 return D_O_K;
5389 }
5390
5391 960146176 bool is_Fkey(int32_t k)
5392 {
5393
2/2
✓ Branch 0 taken 97641984 times.
✓ Branch 1 taken 862504192 times.
960146176 switch(k)
5394 {
5395 case KEY_F1:
5396 case KEY_F2:
5397 case KEY_F3:
5398 case KEY_F4:
5399 case KEY_F5:
5400 case KEY_F6:
5401 case KEY_F7:
5402 case KEY_F8:
5403 case KEY_F9:
5404 case KEY_F10:
5405 case KEY_F11:
5406 case KEY_F12:
5407 97641984 return true;
5408 }
5409
5410 862504192 return false;
5411 960146176 }
5412
5413 void kb_getkey(DIALOG *d);
5414
5415 //Used by all keyboard key settings dialogues.
5416 void kb_clearjoystick(DIALOG *d)
5417 {
5418 d->flags|=D_SELECTED;
5419
5420 jwin_button_proc(MSG_DRAW,d,0);
5421 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5422 // text_mode(vc(11));
5423 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5424 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5425
5426 update_hw_screen(true);
5427
5428 clear_keybuf();
5429 int32_t k = next_press_key();
5430 clear_keybuf();
5431
5432 //shnarf
5433 //47=f1
5434 //59=esc
5435 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5436 // *((int32_t*)d->dp3) = k;
5437 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5438
5439
5440 d->flags&=~D_SELECTED;
5441 }
5442
5443 //Clears key to 0.
5444 //Used by all keyboard key settings dialogues.
5445 void kb_clearkey(DIALOG *d);
5446
5447 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5448 {
5449 switch(msg)
5450 {
5451 case MSG_KEY:
5452 case MSG_CLICK:
5453
5454 kb_clearjoystick(d);
5455
5456 while(gui_mouse_b())
5457 {
5458 clear_keybuf();
5459 rest(1);
5460 }
5461
5462 return D_REDRAW;
5463 }
5464
5465 return jwin_button_proc(msg,d,c);
5466 }
5467
5468 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5469 //Only used in keyboard settings dialogues to clear keys.
5470 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5471
5472 void j_getbtn(DIALOG *d)
5473 {
5474 d->flags|=D_SELECTED;
5475 jwin_button_proc(MSG_DRAW,d,0);
5476 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5477 // text_mode(vc(11));
5478 int32_t y = gui_bmp->h/2 - 12;
5479 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5480 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5481 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5482
5483 update_hw_screen(true);
5484
5485 int32_t b = next_press_btn();
5486
5487 if(b>=0)
5488 *((int32_t*)d->dp3) = b;
5489
5490 d->flags&=~D_SELECTED;
5491
5492 if (player)
5493 player->joy_on = TRUE;
5494 }
5495
5496 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5497 {
5498 switch(msg)
5499 {
5500 case MSG_KEY:
5501 case MSG_CLICK:
5502
5503 j_getbtn(d);
5504
5505 while(gui_mouse_b()) {
5506 rest(1);
5507 clear_keybuf();
5508 }
5509
5510 return D_REDRAW;
5511 }
5512
5513 return jwin_button_proc(msg,d,c);
5514 }
5515
5516 //shnarf
5517 extern const char *key_str[];
5518 std::string get_keystr(int key);
5519
5520 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5521 //extern int32_t zcmusic_bufsz;
5522
5523 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5524 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5525
5526 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5527 {
5528 //these are here to bypass compiler warnings about unused arguments
5529 c=c;
5530
5531 if(msg==MSG_DRAW)
5532 {
5533 switch(d->w)
5534 {
5535 case 0:
5536 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5537 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5538 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5539 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5540 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5541 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5542 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5543 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5544 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5545 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5546 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5547 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5548 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5549 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5550 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5551 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5552 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5553 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5554 break;
5555
5556 case 1:
5557 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5558 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5559 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5560 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5561 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5562 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5563 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5564 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5565 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5566 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5567 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5568 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5569 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5570 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5571 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5572 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5573 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5574 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5575 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5576 break;
5577
5578 case 2:
5579 sprintf(str_a," %3d",midi_volume);
5580 sprintf(str_b," %3d",digi_volume);
5581 sprintf(str_l," %3d",emusic_volume);
5582 sprintf(str_m," %3dKB",zcmusic_bufsz);
5583 sprintf(str_r," %3d",sfx_volume);
5584 strcpy(str_s,pan_str[pan_style]);
5585 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5586 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5587 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5588 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5589 break;
5590 }
5591 }
5592
5593 return D_O_K;
5594 }
5595
5596 int32_t set_vol(void *dp3, int32_t d2)
5597 {
5598 switch(((int32_t*)dp3)[0])
5599 {
5600 case 0:
5601 midi_volume = zc_min(d2<<3,255);
5602 break;
5603
5604 case 1:
5605 digi_volume = zc_min(d2<<3,255);
5606 break;
5607
5608 case 2:
5609 emusic_volume = zc_min(d2<<3,255);
5610 break;
5611
5612 case 3:
5613 sfx_volume = zc_min(d2<<3,255);
5614 break;
5615 }
5616
5617 // text_mode(vc(11));
5618 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5619 return D_O_K;
5620 }
5621
5622 int32_t set_pan(void *dp3, int32_t d2)
5623 {
5624 pan_style = vbound(d2,0,3);
5625 // text_mode(vc(11));
5626 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5627 return D_O_K;
5628 }
5629
5630 int32_t set_buf(void *dp3, int32_t d2)
5631 {
5632 // text_mode(vc(11));
5633 zcmusic_bufsz = d2 + 1;
5634 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5635 return D_O_K;
5636 }
5637
5638 static int32_t gamepad_btn_list[] =
5639 {
5640 6,
5641 7,8,9,10,11,12,13,14,15,16,17,
5642 18,19,20,21,22,23,24,25,26,27,28,
5643 29,30,31,32,33,34,35,36,37,38,39,
5644 -1
5645 };
5646
5647 static int32_t gamepad_dirs_list[] =
5648 {
5649 40,41,42,43,
5650 44,45,46,47,
5651 48,49,50,51,
5652 52,53,54,55,
5653 56,
5654 -1
5655 };
5656
5657 static TABPANEL gamepad_tabs[] =
5658 {
5659 // (text)
5660 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5661 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5662 { NULL, 0, NULL, 0, NULL }
5663 };
5664
5665 static DIALOG gamepad_dlg[] =
5666 {
5667 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5668 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5669 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5670 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5671 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5672 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5673 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5674 // 6
5675 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5676 // 7
5677 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5678 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5679 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5680 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5681 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5682 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5683 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5684 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5685 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5686 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5687 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5688 // 18
5689 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5690 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5691 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5692 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5693 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5694 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5695 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5696 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5697 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5698 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5699 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5700 // 29
5701 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5702 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5703 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5704 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5705 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5706 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5707 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5708 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5709 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5710 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5711 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5712 // 40
5713 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5714 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5715 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5716 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5717 // 44
5718 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5719 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5720 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5721 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5722 // 48
5723 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5724 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5725 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5726 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5727 // 52
5728 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5729 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5730 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5731 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5732 // 56
5733 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5734 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5735 };
5736
5737 static int32_t keyboard_keys_list[] =
5738 {
5739 6,7,8,9,10,
5740 11,12,13,14,15,16,17,18,19,20,
5741 21,22,23,24,25,26,27,28,29,30,
5742 31,32,33,34,35,36,37,38,39,40,
5743 -1
5744 };
5745
5746 static int32_t keyboard_dirs_list[] =
5747 {
5748 41,42,43,44,
5749 45,46,47,48,
5750 49,50,51,52,
5751 53,54,55,56,
5752 -1
5753 };
5754
5755 static int32_t keyboard_mods_list[] =
5756 {
5757 57,58,59,60,
5758 61,62,63,64,
5759 65,66,67,68,
5760 69,70,71,72,
5761 -1
5762 };
5763
5764 static TABPANEL keyboard_control_tabs[] =
5765 {
5766 // (text)
5767 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5768 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5769 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5770 { NULL, 0, NULL, 0, NULL }
5771 };
5772
5773 static DIALOG keyboard_control_dlg[] =
5774 {
5775 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5776 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5777 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5778 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5779 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5780 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5781 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5782 // Keys
5783 // 6
5784 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5785 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5786 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5788 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5789 // 11
5790 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5791 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5792 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5793 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5794 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5795 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5796 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5797 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5798 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5799 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5800 // 21
5801 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5802 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5803 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5804 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5805 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5806 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5807 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5808 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5809 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5810 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5811 // 31
5812 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5813 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5814 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5815 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5816 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5817 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5818 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5819 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5820 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5821 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5822 // Dirs
5823 // 41
5824 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5825 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5826 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5827 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5828 // 45
5829 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5830 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5831 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5832 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5833 // 49
5834 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5835 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5836 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5837 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5838 // 53
5839 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5840 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5841 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5842 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5843 // Mods
5844 // 57
5845 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5846 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5847 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5848 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5849 // 61
5850 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5851 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5852 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5853 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5854 // 65
5855 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5856 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5857 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5858 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5859 // 69
5860 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5861 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5862 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5863 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5864 // 73
5865 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5866 };
5867
5868 /*
5869 int32_t midi_dp[3] = {0,147,104};
5870 int32_t digi_dp[3] = {1,147,120};
5871 int32_t pan_dp[3] = {0,147,136};
5872 int32_t buf_dp[3] = {0,147,152};
5873 */
5874 int32_t midi_dp[3] = {0,0,0};
5875 int32_t digi_dp[3] = {1,0,0};
5876 int32_t emus_dp[3] = {2,0,0};
5877 int32_t buf_dp[3] = {0,0,0};
5878 int32_t sfx_dp[3] = {3,0,0};
5879 int32_t pan_dp[3] = {0,0,0};
5880
5881 static DIALOG sound_dlg[] =
5882 {
5883 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5884 34 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5885 34 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5886 34 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5887 34 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5888 34 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5889 34 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5890 34 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5891 34 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5892 34 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5893 34 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5894 // 10
5895 34 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5896 34 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5897 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5898 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5899 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5900 34 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5901 34 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5902 34 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5903 34 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5904 34 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5905 //20
5906 34 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5907 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5908 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5909 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5910 34 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5911 34 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5912 34 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5913 34 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5914 34 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5915 34 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5916 //30
5917 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5918 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5919 34 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5920 34 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5921 };
5922
5923 char zc_builddate[80];
5924 char zc_aboutstr[80];
5925
5926 static DIALOG about_dlg[] =
5927 {
5928 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5929 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5930 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5931 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5932 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5933 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5934 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5935 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5936 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5937 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5938 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5939 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5940 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5941 };
5942
5943
5944 static DIALOG quest_dlg[] =
5945 {
5946 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5947 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5948 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5949 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5950 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5951 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5952 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5953 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5954 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5955 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5956 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5957 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5958 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5959 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5960 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5961 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5962 };
5963
5964 static DIALOG triforce_dlg[] =
5965 {
5966 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5967 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5968 // 1
5969 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5970 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5971 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5972 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5973 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5974 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5975 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5976 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5977 // 9
5978 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5979 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5980 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5981 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5982 };
5983
5984 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5985 {
5986 go();
5987 int32_t ret=0;
5988 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5989 comeback();
5990 return ret != 0;
5991 }
5992
5993
5994 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5995 {
5996 if(def!=modulepath)
5997 strcpy(modulepath,def);
5998
5999 if(!usefilename)
6000 {
6001 int32_t i=(int32_t)strlen(modulepath);
6002
6003 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6004 modulepath[i--]=0;
6005 }
6006
6007 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6008 int32_t ret=0;
6009 int32_t sel=0;
6010
6011 if(list==NULL)
6012 {
6013 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6014 }
6015 else
6016 {
6017 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6018 }
6019
6020 return ret!=0;
6021 }
6022
6023 //The Dialogue that loads a ZMOD Module File
6024 int32_t zc_load_zmod_module_file()
6025 {
6026 if ( Playing )
6027 {
6028 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6029 return -1;
6030 }
6031 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6032 return D_CLOSE;
6033
6034 FILE *tempmodule = fopen(modulepath,"r");
6035
6036 if(tempmodule == NULL)
6037 {
6038 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
6039 return -1;
6040 }
6041
6042
6043 //Set the module path:
6044 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6045 strcpy(moduledata.module_name, modulepath);
6046 al_trace("New Module Path is: %s \n", moduledata.module_name);
6047 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6048 zcm.init(true); //Load the module values.
6049 moduledata.refresh_title_screen = 1;
6050 // refresh_select_screen = 1;
6051 build_biic_list();
6052 return D_O_K;
6053 }
6054
6055 static DIALOG module_info_dlg[] =
6056 {
6057 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6058
6059
6060 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6061 //1
6062 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6063 //2
6064 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6065 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6066 //4
6067 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6068 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6069 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6070 //7
6071
6072 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6073 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6074 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6075 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6076 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6077 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6078 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6079 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6080 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6081
6082 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6083 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6084 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6085 };
6086
6087 void about_zcplayer_module(const char *prompt,int32_t initialval)
6088 {
6089
6090 module_info_dlg[0].dp2 = get_zc_font(font_lfont);
6091 if ( moduledata.moduletitle[0] != 0 )
6092 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6093
6094 if ( moduledata.moduleauthor[0] != 0 )
6095 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6096
6097 if ( moduledata.moduleinfo0[0] != 0 )
6098 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6099 if ( moduledata.moduleinfo1[0] != 0 )
6100 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6101 if ( moduledata.moduleinfo2[0] != 0 )
6102 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6103 if ( moduledata.moduleinfo3[0] != 0 )
6104 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6105 if ( moduledata.moduleinfo4[0] != 0 )
6106 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6107
6108 char module_date[255];
6109 memset(module_date, 0, sizeof(module_date));
6110 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6111 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6112
6113
6114
6115 char module_vers[255];
6116 memset(module_vers, 0, sizeof(module_vers));
6117 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6118
6119
6120 //sprintf(tilecount,"%d",1);
6121
6122 char module_build[255];
6123 memset(module_build, 0, sizeof(module_build));
6124 if ( moduledata.modbeta )
6125 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6126 else
6127 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6128
6129 module_info_dlg[12].dp = (char*)module_date;
6130 module_info_dlg[13].dp = (char*)module_vers;
6131 module_info_dlg[14].dp = (char*)module_build;
6132
6133 large_dialog(module_info_dlg);
6134
6135 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6136 jwin_center_dialog(module_info_dlg);
6137
6138
6139 }
6140
6141 int32_t onAbout_ZCP_Module()
6142 {
6143 about_zcplayer_module("About Module (.zmod)", 0);
6144 return D_O_K;
6145 }
6146
6147 //New Modules Menu for 2.55+
6148 static MENU zcmodule_menu[] =
6149 {
6150 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6151 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6152
6153 { NULL, NULL, NULL, 0, NULL }
6154 };
6155
6156 int32_t onToggleRecordingNewSaves()
6157 {
6158 if (zc_get_config("zeldadx", "replay_new_saves", false))
6159 {
6160 zc_set_config("zeldadx", "replay_new_saves", false);
6161 }
6162 else
6163 {
6164 zc_set_config("zeldadx", "replay_new_saves", true);
6165 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6166 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6167 }
6168 return D_O_K;
6169 }
6170
6171 int32_t onToggleSnapshotAllFrames()
6172 {
6173 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6174 return D_O_K;
6175 }
6176
6177 int32_t onStopReplayOrRecord()
6178 {
6179 if (replay_is_replaying())
6180 {
6181 replay_quit();
6182 }
6183 else if (replay_get_mode() == ReplayMode::Record)
6184 {
6185 if (!replay_get_meta_bool("test_mode"))
6186 {
6187 jwin_alert("Recording", "You cannot stop recording a save file.",
6188 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6189 return D_CLOSE;
6190 }
6191
6192 if (jwin_alert("Stop Recording",
6193 "Save replay to disk and stop recording?",
6194 "This will stop the recording.",
6195 NULL,
6196 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6197 return D_CLOSE;
6198
6199 replay_save();
6200 replay_stop();
6201 }
6202 return D_O_K;
6203 }
6204
6205 static int32_t handle_on_load_replay(ReplayMode mode)
6206 {
6207 if (Playing)
6208 {
6209 if (jwin_alert("Replay - Warning!",
6210 "Loading a replay will exit the current game.",
6211 "All unsaved progress will be lost.",
6212 "Do you wish to continue?",
6213 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6214 return D_CLOSE;
6215 }
6216
6217 std::string mode_string = replay_mode_to_string(mode);
6218 mode_string[0] = std::toupper(mode_string[0]);
6219
6220 std::string line_1 = "Select a replay file to play back.";
6221 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6222 std::string line_3 = "You can stop the replay and take over manually any time.";
6223 if (mode == ReplayMode::Update)
6224 {
6225 line_1 = "Select a replay file to update.";
6226 line_2 = "WARNING: be sure to back up the zplay file";
6227 line_3 = "and verify that the updated replay works as expected!";
6228 }
6229
6230 if (jwin_alert(mode_string.c_str(),
6231 line_1.c_str(),
6232 line_2.c_str(),
6233 line_3.c_str(),
6234 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6235 {
6236 char replay_path[2048];
6237 strcpy(replay_path, "replays/");
6238 if (jwin_file_select_ex(
6239 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6240 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6241 return D_CLOSE;
6242
6243 replay_quit();
6244 load_replay_file_deferred(mode, replay_path);
6245 Quit = qRESET;
6246 return D_CLOSE;
6247 }
6248 return D_O_K;
6249 }
6250
6251 int32_t onLoadReplay()
6252 {
6253 return handle_on_load_replay(ReplayMode::Replay);
6254 }
6255
6256 int32_t onLoadReplayAssert()
6257 {
6258 return handle_on_load_replay(ReplayMode::Assert);
6259 }
6260
6261 int32_t onLoadReplayUpdate()
6262 {
6263 return handle_on_load_replay(ReplayMode::Update);
6264 }
6265
6266 int32_t onSaveReplay()
6267 {
6268 if (replay_get_mode() == ReplayMode::Record)
6269 {
6270 if (!replay_get_meta_bool("test_mode"))
6271 {
6272 if (jwin_alert("Save Replay",
6273 "This will save a copy of the replay up to this point.",
6274 "The official replay file will be untouched.",
6275 "Do you wish to continue?",
6276 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6277 return D_CLOSE;
6278
6279 char replay_path[2048];
6280 strcpy(replay_path, replay_get_replay_path().string().c_str());
6281 if (jwin_file_select_ex(
6282 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6283 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6284 return D_CLOSE;
6285
6286 if (fileexists(replay_path))
6287 {
6288 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6289 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6290 return D_CLOSE;
6291 }
6292
6293 replay_save(replay_path);
6294 }
6295 else
6296 {
6297 replay_save();
6298 }
6299 }
6300 return D_O_K;
6301 }
6302
6303 static MENU replay_menu[] =
6304 {
6305 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6306 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6307 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6308 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6309 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6310 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6311 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6312
6313 { NULL, NULL, NULL, 0, NULL }
6314 };
6315
6316 static DIALOG credits_dlg[] =
6317 {
6318 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6319 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6320 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6321 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6322 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6323 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6324 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6325 };
6326
6327 34 static ListData dmap_list(dmaplist, &font);
6328
6329 static DIALOG goto_dlg[] =
6330 {
6331 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6332 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6333 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6334 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6335 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6336 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6337 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6338 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6339 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6340 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6341 };
6342
6343 int32_t onGoTo()
6344 {
6345 bool music = false;
6346 music = music;
6347 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6348
6349 goto_dlg[0].dp2=get_zc_font(font_lfont);
6350 goto_dlg[4].d2=cheat_goto_dmap;
6351 goto_dlg[6].dp=cheat_goto_screen_str;
6352
6353 clear_keybuf();
6354
6355 large_dialog(goto_dlg);
6356
6357 if(zc_popup_dialog(goto_dlg,4)==1)
6358 {
6359 // dmap, screen
6360 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6361 };
6362
6363 return D_O_K;
6364 }
6365
6366 int32_t onGoToComplete()
6367 {
6368 if(!Playing)
6369 {
6370 return D_O_K;
6371 }
6372
6373 system_pal();
6374 music_pause();
6375 pause_all_sfx();
6376 sys_mouse();
6377 onGoTo();
6378 eat_buttons();
6379
6380 zc_readrawkey(KEY_ESC);
6381
6382 game_mouse();
6383 game_pal();
6384 music_resume();
6385 resume_all_sfx();
6386 return D_O_K;
6387 }
6388
6389 int32_t onCredits()
6390 {
6391 go();
6392
6393 BITMAP *win = create_bitmap_ex(8,222,110);
6394
6395 if(!win)
6396 return D_O_K;
6397
6398 int32_t c=0;
6399 int32_t l=0;
6400 int32_t ol=-1;
6401 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6402 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6403 PALETTE tmppal;
6404
6405 rti_gui.transparency_index = 1;
6406
6407 clear_to_color(win, rti_gui.transparency_index);
6408 draw_rle_sprite(win,rle,0,0);
6409 credits_dlg[0].dp2=get_zc_font(font_lfont);
6410 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6411 credits_dlg[2].dp = win;
6412
6413 zc_set_palette_range(black_palette,0,127,false);
6414
6415 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6416
6417 BITMAP* old_screen = screen;
6418 BITMAP* gui_bmp = zc_get_gui_bmp();
6419 ASSERT(gui_bmp);
6420 clear_to_color(gui_bmp, rti_gui.transparency_index);
6421 screen = gui_bmp;
6422
6423 while(update_dialog(p))
6424 {
6425 throttleFPS();
6426 ++c;
6427 l = zc_max((c>>1)-30,0);
6428
6429 if(l > rle->h)
6430 l = c = 0;
6431
6432 if(l > rle->h - 112)
6433 l = rle->h - 112;
6434
6435 clear_bitmap(win);
6436 draw_rle_sprite(win,rle,0,0-l);
6437
6438 if(c<=64)
6439 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6440
6441 zc_set_palette_range(tmppal,0,127,false);
6442
6443 if(l!=ol)
6444 {
6445 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6446 SCRFIX();
6447 ol=l;
6448 }
6449
6450 update_hw_screen();
6451 }
6452
6453 screen = old_screen;
6454 system_pal();
6455
6456 shutdown_dialog(p);
6457 destroy_bitmap(win);
6458 //comeback();
6459
6460 rti_gui.transparency_index = 0;
6461 clear_to_color(gui_bmp, rti_gui.transparency_index);
6462
6463 return D_O_K;
6464 }
6465
6466 const char *midilist(int32_t index, int32_t *list_size)
6467 {
6468 if(index<0)
6469 {
6470 *list_size=0;
6471
6472 for(int32_t i=0; i<MAXMIDIS; i++)
6473 if(tunes[i].data)
6474 ++(*list_size);
6475
6476 return NULL;
6477 }
6478
6479 int32_t i=0,m=0;
6480
6481 while(m<=index && i<=MAXMIDIS)
6482 {
6483 if(tunes[i].data)
6484 ++m;
6485
6486 ++i;
6487 }
6488
6489 --i;
6490
6491 if(i==MAXMIDIS && m<index)
6492 return "(null)";
6493
6494 return tunes[i].title;
6495 }
6496
6497 /* ------- MIDI info stuff -------- */
6498
6499 char *text;
6500 midi_info *zmi;
6501 bool dialog_running;
6502 bool listening;
6503
6504 void get_info(int32_t index);
6505
6506 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6507 {
6508 int32_t d2 = d->d2;
6509 int32_t ret = jwin_droplist_proc(msg,d,c);
6510
6511 if(d2!=d->d2)
6512 {
6513 get_info(d->d2);
6514 }
6515
6516 return ret;
6517 }
6518
6519 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6520 {
6521 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6522
6523 int32_t ret = jwin_button_proc(msg,d,c);
6524
6525 if(ret == D_CLOSE)
6526 {
6527 // get current midi index
6528 int32_t index = (d+(d->d1))->d2;
6529 int32_t i=0, m=0;
6530
6531 while(m<=index && i<=MAXMIDIS)
6532 {
6533 if(tunes[i].data)
6534 ++m;
6535
6536 ++i;
6537 }
6538
6539 --i;
6540 jukebox(i);
6541 listening = true;
6542 ret = D_O_K;
6543 }
6544
6545 return ret;
6546 }
6547
6548 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6549 {
6550 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6551
6552 int32_t ret = jwin_button_proc(msg,d,c);
6553
6554 if(ret == D_CLOSE)
6555 {
6556 // get current midi index
6557 int32_t index = (d+(d->d1))->d2;
6558 int32_t i=0, m=0;
6559
6560 while(m<=index && i<=MAXMIDIS)
6561 {
6562 if(tunes[i].data)
6563 ++m;
6564
6565 ++i;
6566 }
6567
6568 --i;
6569
6570 // get file name
6571
6572 int32_t sel=0;
6573 //struct ffblk f;
6574 char title[40] = "Save MIDI: ";
6575 char fname[2048];
6576 memset(fname,0,2048);
6577 static EXT_LIST list[] =
6578 {
6579 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6580 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6581 { NULL, NULL }
6582 };
6583
6584 strcpy(title+11, tunes[i].title);
6585 title[39] = '\0';
6586
6587 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6588 goto done;
6589
6590 if(exists(fname))
6591 {
6592 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6593 goto done;
6594 }
6595
6596 // save midi i
6597
6598 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6599 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6600
6601 done:
6602 chop_path(fname);
6603 ret = D_REDRAW;
6604 }
6605
6606 return ret;
6607 }
6608
6609 34 static ListData midi_list(midilist, &font);
6610
6611 static DIALOG midi_dlg[] =
6612 {
6613 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6614 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6615 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6616 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6617 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6618 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6619 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6620 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6621 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6622 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6623 };
6624
6625 void get_info(int32_t index)
6626 {
6627 int32_t i=0, m=0;
6628
6629 while(m<=index && i<=MAXMIDIS)
6630 {
6631 if(tunes[i].data)
6632 ++m;
6633
6634 ++i;
6635 }
6636
6637 --i;
6638
6639 if(i==MAXMIDIS && m<index)
6640 strcpy(text,"(null)");
6641 else
6642 {
6643 get_midi_info((MIDI*)tunes[i].data,zmi);
6644 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6645 }
6646
6647 midi_dlg[0].dp2=get_zc_font(font_lfont);
6648 midi_dlg[3].dp = text;
6649 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6650 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6651
6652 if(dialog_running)
6653 {
6654 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6655 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6656 }
6657 }
6658
6659 int32_t onMIDICredits()
6660 {
6661 text = (char*)malloc(4096);
6662 zmi = (midi_info*)malloc(sizeof(midi_info));
6663
6664 if(!text || !zmi)
6665 {
6666 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6667 return D_O_K;
6668 }
6669
6670 bool do_pause_midi = midi_pos >= 0 && currmidi;
6671 auto restore_midi = currmidi;
6672 if(do_pause_midi)
6673 {
6674 paused_midi_pos = midi_pos;
6675 stop_midi();
6676 midi_paused=true;
6677 midi_suspended = midissuspHALTED;
6678 }
6679
6680 midi_dlg[0].dp2=get_zc_font(font_lfont);
6681 midi_dlg[2].d1 = 0;
6682 midi_dlg[2].d2 = 0;
6683 midi_dlg[4].flags = D_EXIT;
6684 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6685
6686 listening = false;
6687 dialog_running=false;
6688 get_info(0);
6689
6690 dialog_running=true;
6691
6692 large_dialog(midi_dlg);
6693
6694 zc_popup_dialog(midi_dlg,0);
6695 dialog_running=false;
6696
6697 if(listening)
6698 music_stop();
6699
6700 if(do_pause_midi)
6701 {
6702 midi_suspended = midissuspRESUME;
6703 currmidi = restore_midi;
6704 midi_pos = paused_midi_pos;
6705 }
6706
6707 if(text) free(text);
6708 if(zmi) free(zmi);
6709 return D_O_K;
6710 }
6711
6712 int32_t onAbout()
6713 {
6714 char buf1[80]={0};
6715 std::ostringstream oss;
6716 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6717 oss << buf1 << '\n';
6718 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6719 oss << buf1 << '\n';
6720 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6721 oss << buf1 << '\n';
6722 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6723 oss << buf1 << '\n';
6724 sprintf(buf1, "Tag: %s", getReleaseTag());
6725 oss << buf1 << '\n';
6726
6727 InfoDialog("About ZC", oss.str()).show();
6728 return D_O_K;
6729 }
6730
6731 int32_t onQuest()
6732 {
6733 char fname[100];
6734 strcpy(fname, get_filename(qstpath));
6735 quest_dlg[0].dp2=get_zc_font(font_lfont);
6736 quest_dlg[1].dp = fname;
6737
6738 if(QHeader.quest_number==0)
6739 sprintf(str_a,"Custom");
6740 else
6741 sprintf(str_a,"%d",QHeader.quest_number);
6742
6743 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6744
6745 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6746 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6747
6748 large_dialog(quest_dlg);
6749
6750 zc_popup_dialog(quest_dlg, 0);
6751 return D_O_K;
6752 }
6753
6754 void call_vidmode_dlg();
6755 int32_t onVidMode()
6756 {
6757 call_vidmode_dlg();
6758 return D_O_K;
6759 }
6760
6761 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6762 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6763 //Added an extra statement, so that if the key is cleared to 0, the cleared
6764 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6765
6766 void load_ukeys(int32_t* arr)
6767 {
6768 arr[ukey_a] = Akey;
6769 arr[ukey_b] = Bkey;
6770 arr[ukey_s] = Skey;
6771 arr[ukey_l] = Lkey;
6772 arr[ukey_r] = Rkey;
6773 arr[ukey_p] = Pkey;
6774 arr[ukey_ex1] = Exkey1;
6775 arr[ukey_ex2] = Exkey2;
6776 arr[ukey_ex3] = Exkey3;
6777 arr[ukey_ex4] = Exkey4;
6778 arr[ukey_du] = DUkey;
6779 arr[ukey_dd] = DDkey;
6780 arr[ukey_dl] = DLkey;
6781 arr[ukey_dr] = DRkey;
6782 arr[ukey_mod1a] = cheat_modifier_keys[0];
6783 arr[ukey_mod1b] = cheat_modifier_keys[1];
6784 arr[ukey_mod2a] = cheat_modifier_keys[2];
6785 arr[ukey_mod2b] = cheat_modifier_keys[3];
6786 };
6787
6788 static const char* ukey_names[] = {
6789 "A", "B", "Start", "L", "R", "Map",
6790 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6791 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6792 "Cheat Mod R1", "Cheat Mod R2",
6793 };
6794 std::string get_ukey_name(int32_t k)
6795 {
6796 if (k < num_ukey) return ukey_names[k];
6797 return "";
6798 }
6799
6800 int32_t onKeyboard()
6801 {
6802 int32_t a = Akey;
6803 int32_t b = Bkey;
6804 int32_t s = Skey;
6805 int32_t l = Lkey;
6806 int32_t r = Rkey;
6807 int32_t p = Pkey;
6808 int32_t ex1 = Exkey1;
6809 int32_t ex2 = Exkey2;
6810 int32_t ex3 = Exkey3;
6811 int32_t ex4 = Exkey4;
6812 int32_t du = DUkey;
6813 int32_t dd = DDkey;
6814 int32_t dl = DLkey;
6815 int32_t dr = DRkey;
6816 int32_t mod1a = cheat_modifier_keys[0];
6817 int32_t mod1b = cheat_modifier_keys[1];
6818 int32_t mod2a = cheat_modifier_keys[2];
6819 int32_t mod2b = cheat_modifier_keys[3];
6820 bool done=false;
6821 int32_t ret;
6822
6823 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6824
6825 large_dialog(keyboard_control_dlg);
6826
6827 while(!done)
6828 {
6829 ret = zc_popup_dialog(keyboard_control_dlg,3);
6830
6831 if(ret==3) // OK
6832 {
6833 int32_t ukeys[num_ukey];
6834 load_ukeys(ukeys);
6835 std::vector<std::string> uniqueError;
6836 for(int32_t q = 0; q < num_ukey; ++q)
6837 {
6838 for(int32_t p = q+1; p < num_ukey; ++p)
6839 {
6840 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6841 {
6842 char buf[64];
6843 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6844 std::string str(buf);
6845 uniqueError.push_back(str);
6846 }
6847 }
6848 }
6849 if(uniqueError.size() == 0)
6850 {
6851 done = true;
6852 save_control_configs(true);
6853 }
6854 else
6855 {
6856 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6857 box_out("Cannot have duplicate keybinds!"); box_eol();
6858 for(std::vector<std::string>::iterator it = uniqueError.begin();
6859 it != uniqueError.end(); ++it)
6860 {
6861 box_out((*it).c_str()); box_eol();
6862 }
6863 box_end(true);
6864 }
6865 }
6866 else // Cancel
6867 {
6868 Akey = a;
6869 Bkey = b;
6870 Skey = s;
6871 Lkey = l;
6872 Rkey = r;
6873 Pkey = p;
6874 Exkey1 = ex1;
6875 Exkey2 = ex2;
6876 Exkey3 = ex3;
6877 Exkey4 = ex4;
6878 DUkey = du;
6879 DDkey = dd;
6880 DLkey = dl;
6881 DRkey = dr;
6882 cheat_modifier_keys[0] = mod1a;
6883 cheat_modifier_keys[1] = mod1b;
6884 cheat_modifier_keys[2] = mod2a;
6885 cheat_modifier_keys[3] = mod2b;
6886
6887 done=true;
6888 }
6889
6890 rest(1);
6891 }
6892
6893 return D_O_K;
6894 }
6895
6896 int32_t onGamepad()
6897 {
6898 int32_t a = Abtn;
6899 int32_t b = Bbtn;
6900 int32_t s = Sbtn;
6901 int32_t l = Lbtn;
6902 int32_t r = Rbtn;
6903 int32_t m = Mbtn;
6904 int32_t p = Pbtn;
6905 int32_t ex1 = Exbtn1;
6906 int32_t ex2 = Exbtn2;
6907 int32_t ex3 = Exbtn3;
6908 int32_t ex4 = Exbtn4;
6909 int32_t up = DUbtn;
6910 int32_t down = DDbtn;
6911 int32_t left = DLbtn;
6912 int32_t right = DRbtn;
6913
6914 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6915 if(analog_movement)
6916 gamepad_dlg[56].flags|=D_SELECTED;
6917 else
6918 gamepad_dlg[56].flags&=~D_SELECTED;
6919
6920 large_dialog(gamepad_dlg);
6921
6922 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6923
6924 if(ret == 4) //OK
6925 {
6926 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6927 save_control_configs(false);
6928 }
6929 else //Cancel
6930 {
6931 Abtn = a;
6932 Bbtn = b;
6933 Sbtn = s;
6934 Lbtn = l;
6935 Rbtn = r;
6936 Mbtn = m;
6937 Pbtn = p;
6938 Exbtn1 = ex1;
6939 Exbtn2 = ex2;
6940 Exbtn3 = ex3;
6941 Exbtn4 = ex4;
6942 DUbtn = up;
6943 DDbtn = down;
6944 DLbtn = left;
6945 DRbtn = right;
6946 }
6947
6948 return D_O_K;
6949 }
6950
6951 int32_t onCheatKeys()
6952 {
6953 int32_t oldcheats[Cheat::Last][2];
6954 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6955
6956 bool done=false;
6957
6958 while(!done)
6959 {
6960 bool confirm = false;
6961 CheatKeysDialog(&confirm).show();
6962 if(confirm) // OK
6963 {
6964 std::vector<std::string> uniqueError;
6965 char buf[512];
6966 for(size_t q = 1; q < Cheat::Last; ++q)
6967 {
6968 if(cheatkeys[q][1] && !cheatkeys[q][0])
6969 {
6970 cheatkeys[q][0] = cheatkeys[q][1];
6971 cheatkeys[q][1] = 0;
6972 }
6973 }
6974 for(size_t q = 1; q < Cheat::Last; ++q)
6975 {
6976 if(!bindable_cheat((Cheat)q)) continue;
6977 for(size_t p = q+1; p < Cheat::Last; ++p)
6978 {
6979 if(!bindable_cheat((Cheat)p)) continue;
6980 for(size_t q2 = 0; q2 <= 1; ++q2)
6981 for(size_t p2 = 0; p2 <= 1; ++p2)
6982 {
6983 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6984 {
6985 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6986 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6987 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6988 get_keystr(cheatkeys[q][q2])));
6989 }
6990 }
6991 }
6992 }
6993 if(uniqueError.size() == 0)
6994 {
6995 done = true;
6996 save_cheatkeys();
6997 }
6998 else
6999 {
7000 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
7001 box_out("Cannot have duplicate keybinds!"); box_eol();
7002 for(std::vector<std::string>::iterator it = uniqueError.begin();
7003 it != uniqueError.end(); ++it)
7004 {
7005 box_out((*it).c_str()); box_eol();
7006 }
7007 box_end(true);
7008 }
7009 }
7010 else // Cancel
7011 {
7012 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
7013 done=true;
7014 }
7015 rest(1);
7016 }
7017
7018 return D_O_K;
7019 }
7020
7021 int32_t onSound()
7022 {
7023 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7024 {
7025 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7026 }
7027 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7028 {
7029 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7030 }
7031 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7032 {
7033 emusic_volume = (int32_t)FFCore.usr_music_volume;
7034 }
7035 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7036 {
7037 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7038 }
7039 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7040 {
7041 pan_style = (int32_t)FFCore.usr_panstyle;
7042 }
7043
7044 int32_t m = midi_volume;
7045 int32_t d = digi_volume;
7046 int32_t e = emusic_volume;
7047 int32_t b = zcmusic_bufsz;
7048 int32_t s = sfx_volume;
7049 int32_t p = pan_style;
7050 pan_style = vbound(pan_style,0,3);
7051
7052 sound_dlg[0].dp2=get_zc_font(font_lfont);
7053
7054 large_dialog(sound_dlg);
7055
7056 midi_dp[1] = sound_dlg[6].x;
7057 midi_dp[2] = sound_dlg[6].y;
7058 digi_dp[1] = sound_dlg[7].x;
7059 digi_dp[2] = sound_dlg[7].y;
7060 emus_dp[1] = sound_dlg[8].x;
7061 emus_dp[2] = sound_dlg[8].y;
7062 buf_dp[1] = sound_dlg[9].x;
7063 buf_dp[2] = sound_dlg[9].y;
7064 sfx_dp[1] = sound_dlg[10].x;
7065 sfx_dp[2] = sound_dlg[10].y;
7066 pan_dp[1] = sound_dlg[11].x;
7067 pan_dp[2] = sound_dlg[11].y;
7068 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7069 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7070 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7071 sound_dlg[18].d2 = zcmusic_bufsz;
7072 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7073 sound_dlg[20].d2 = pan_style;
7074
7075 int32_t ret = zc_popup_dialog(sound_dlg,1);
7076
7077 if(ret==2)
7078 {
7079 master_volume(digi_volume,midi_volume);
7080
7081 for(int32_t i=0; i<WAV_COUNT; ++i)
7082 {
7083 //allegro assertion fails when passing in -1 as voice -DD
7084 if(sfx_voice[i] > 0)
7085 voice_set_volume(sfx_voice[i], sfx_volume);
7086 }
7087 zc_set_config(sfx_sect,"digi",digi_volume);
7088 zc_set_config(sfx_sect,"midi",midi_volume);
7089 zc_set_config(sfx_sect,"sfx",sfx_volume);
7090 zc_set_config(sfx_sect,"emusic",emusic_volume);
7091 zc_set_config(sfx_sect,"pan",pan_style);
7092 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7093 }
7094 else
7095 {
7096 midi_volume = m;
7097 digi_volume = d;
7098 emusic_volume = e;
7099 zcmusic_bufsz = b;
7100 sfx_volume = s;
7101 pan_style = p;
7102 }
7103
7104 return D_O_K;
7105 }
7106
7107 int32_t queding(char const* s1, char const* s2, char const* s3)
7108 {
7109 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
7110 }
7111
7112 int32_t onQuit()
7113 {
7114 if(Playing)
7115 {
7116 int32_t ret=0;
7117
7118 if(get_bit(quest_rules, qr_NOCONTINUE))
7119 {
7120 if(standalone_mode)
7121 {
7122 ret=queding("End current game?",
7123 "The continue screen is disabled; the game",
7124 "will be reloaded from the last save.");
7125 }
7126 else
7127 {
7128 ret=queding("End current game?",
7129 "The continue screen is disabled. You will",
7130 "be returned to the file select screen.");
7131 }
7132 }
7133 else
7134 ret=queding("End current game?",NULL,NULL);
7135
7136 if(ret==1)
7137 {
7138 disableClickToFreeze=false;
7139 Quit=qQUIT;
7140
7141 // Trying to evade a door repair charge?
7142 if(repaircharge)
7143 {
7144 game->change_drupy(-repaircharge);
7145 repaircharge=0;
7146 }
7147
7148 return D_CLOSE;
7149 }
7150 }
7151
7152 return D_O_K;
7153 }
7154
7155 int32_t onTryQuitMenu()
7156 {
7157 return onTryQuit(true);
7158 }
7159
7160 int32_t onTryQuit(bool inMenu)
7161 {
7162 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7163 {
7164 if(active_cutscene.can_f6())
7165 {
7166 if(get_bit(quest_rules,qr_OLD_F6))
7167 {
7168 if(inMenu) onQuit();
7169 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7170 }
7171 else
7172 {
7173 disableClickToFreeze=false;
7174 GameFlags |= GAMEFLAG_TRYQUIT;
7175 }
7176 return D_CLOSE;
7177 }
7178 else active_cutscene.error();
7179 }
7180
7181 return D_O_K;
7182 }
7183
7184 int32_t onReset()
7185 {
7186 if(queding(" Reset system? ",NULL,NULL)==1)
7187 {
7188 disableClickToFreeze=false;
7189 Quit=qRESET;
7190 replay_quit();
7191 return D_CLOSE;
7192 }
7193
7194 return D_O_K;
7195 }
7196
7197 int32_t onExit()
7198 {
7199 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7200 {
7201 Quit=qEXIT;
7202 return D_CLOSE;
7203 }
7204
7205 return D_O_K;
7206 }
7207
7208 int32_t onTitle_NES()
7209 {
7210 title_version=0;
7211 zc_set_config(cfg_sect,"title",title_version);
7212 return D_O_K;
7213 }
7214 int32_t onTitle_DX()
7215 {
7216 title_version=1;
7217 zc_set_config(cfg_sect,"title",title_version);
7218 return D_O_K;
7219 }
7220 int32_t onTitle_25()
7221 {
7222 title_version=2;
7223 zc_set_config(cfg_sect,"title",title_version);
7224 return D_O_K;
7225 }
7226
7227 int32_t onDebug()
7228 {
7229 if(debug_enabled)
7230 set_debug(!get_debug());
7231 return D_O_K;
7232 }
7233
7234 int32_t onHeartBeep()
7235 {
7236 heart_beep=!heart_beep;
7237 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7238 return D_O_K;
7239 }
7240
7241 int32_t onSaveIndicator()
7242 {
7243 use_save_indicator=!use_save_indicator;
7244 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7245 return D_O_K;
7246 }
7247
7248 int32_t onEpilepsy()
7249 {
7250 if(jwin_alert3(
7251 "Epilepsy Flash Reduction",
7252 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7253 "Disabling this will restore standard flash and wavy behaviour.",
7254 "Proceed?",
7255 "&Yes",
7256 "&No",
7257 NULL,
7258 'y',
7259 'n',
7260 0,
7261 get_zc_font(font_lfont)) == 1)
7262 {
7263 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7264 zc_set_config("zeldadx","checked_epilepsy",1);
7265 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7266 }
7267 return D_O_K;
7268 }
7269
7270 int32_t onTriforce()
7271 {
7272 for(int32_t i=0; i<MAXINITTABS; ++i)
7273 {
7274 init_tabs[i].flags&=~D_SELECTED;
7275 }
7276
7277 init_tabs[3].flags=D_SELECTED;
7278 return onCheatConsole();
7279 /*triforce_dlg[0].dp2=get_zc_font(font_lfont);
7280 for(int32_t i=1; i<=8; i++)
7281 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7282
7283 if(zc_popup_dialog (triforce_dlg,-1)==9)
7284 {
7285 for(int32_t i=1; i<=8; i++)
7286 {
7287 game->lvlitems[i] &= ~liTRIFORCE;
7288 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7289 }
7290 }
7291 return D_O_K;*/
7292 }
7293
7294 bool rc = false;
7295 /*
7296 int32_t onEquipment()
7297 {
7298 for (int32_t i=0; i<MAXINITTABS; ++i)
7299 {
7300 init_tabs[i].flags&=~D_SELECTED;
7301 }
7302 init_tabs[0].flags=D_SELECTED;
7303 return onCheatConsole();
7304 }
7305 */
7306
7307 int32_t onItems()
7308 {
7309 for(int32_t i=0; i<MAXINITTABS; ++i)
7310 {
7311 init_tabs[i].flags&=~D_SELECTED;
7312 }
7313
7314 init_tabs[1].flags=D_SELECTED;
7315 return onCheatConsole();
7316 }
7317
7318 static DIALOG getnum_dlg[] =
7319 {
7320 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7321 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7322 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7323 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7324 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7325 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7326 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7327 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7328 };
7329
7330 int32_t getnumber(const char *prompt,int32_t initialval)
7331 {
7332 char buf[20];
7333 sprintf(buf,"%d",initialval);
7334 getnum_dlg[0].dp=(void *)prompt;
7335 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7336 getnum_dlg[2].dp=buf;
7337
7338 large_dialog(getnum_dlg);
7339
7340 if(zc_popup_dialog(getnum_dlg,2)==3)
7341 return atoi(buf);
7342
7343 return initialval;
7344 }
7345
7346 int32_t onLife()
7347 {
7348 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7349 cheats_enqueue(Cheat::Life, value);
7350 return D_O_K;
7351 }
7352
7353 int32_t onHeartC()
7354 {
7355 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7356 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7357 cheats_enqueue(Cheat::MaxLife, max_life);
7358 cheats_enqueue(Cheat::Life, life);
7359 return D_O_K;
7360 }
7361
7362 int32_t onMagicC()
7363 {
7364 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7365 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7366 cheats_enqueue(Cheat::MaxMagic, max_magic);
7367 cheats_enqueue(Cheat::Magic, magic);
7368 return D_O_K;
7369 }
7370
7371 int32_t onRupies()
7372 {
7373 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7374 cheats_enqueue(Cheat::Rupies, value);
7375 return D_O_K;
7376 }
7377
7378 int32_t onMaxBombs()
7379 {
7380 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7381 cheats_enqueue(Cheat::MaxBombs, value);
7382 cheats_enqueue(Cheat::Bombs, value);
7383 return D_O_K;
7384 }
7385
7386 int32_t onRefillLife()
7387 {
7388 cheats_enqueue(Cheat::Life, game->get_maxlife());
7389 return D_O_K;
7390 }
7391 int32_t onRefillMagic()
7392 {
7393 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7394 return D_O_K;
7395 }
7396 int32_t onClock()
7397 {
7398 cheats_enqueue(Cheat::Clock);
7399 return D_O_K;
7400 }
7401
7402 int32_t onQstPath()
7403 {
7404 char path[2048];
7405
7406 chop_path(qstdir);
7407 strcpy(path,qstdir);
7408
7409 go();
7410
7411 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7412 {
7413 chop_path(path);
7414 fix_filename_case(path);
7415 fix_filename_slashes(path);
7416 strcpy(qstdir,path);
7417 strcpy(qstpath,qstdir);
7418 }
7419
7420 comeback();
7421 return D_O_K;
7422 }
7423
7424 #include "dialog/cheat_dialog.h"
7425 int32_t onCheat()
7426 {
7427 call_setcheat_dialog();
7428 game->set_cheat(maxcheat);
7429 if(cheat) game->did_cheat(true);
7430 return D_O_K;
7431 }
7432
7433 int32_t onCheatRupies()
7434 {
7435 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7436 return D_O_K;
7437 }
7438
7439 int32_t onCheatArrows()
7440 {
7441 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7442 return D_O_K;
7443 }
7444
7445 int32_t onCheatBombs()
7446 {
7447 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7448 return D_O_K;
7449 }
7450
7451 // *** screen saver
7452
7453 8136832 int32_t after_time()
7454 {
7455
1/2
✓ Branch 0 taken 8136832 times.
✗ Branch 1 not taken.
8136832 if(ss_enable == 0)
7456 return INT_MAX;
7457
7458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
8136832 if(ss_after <= 0)
7459 return 5 * 60;
7460
7461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
8136832 if(ss_after <= 3)
7462 return ss_after * 15 * 60;
7463
7464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8136832 times.
8136832 if(ss_after <= 13)
7465 return (ss_after - 3) * 60 * 60;
7466
7467 8136832 return MAX_IDLE + 1;
7468 8136832 }
7469
7470 static const char *after_str[15] =
7471 {
7472 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7473 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7474 "Never"
7475 };
7476
7477 const char *after_list(int32_t index, int32_t *list_size)
7478 {
7479 if(index < 0)
7480 {
7481 *list_size = 15;
7482 return NULL;
7483 }
7484
7485 return after_str[index];
7486 }
7487
7488 34 static ListData after__list(after_list, &font);
7489
7490 static DIALOG scrsaver_dlg[] =
7491 {
7492 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7493 34 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7494 34 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7495 34 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7496 34 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7497 34 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7498 34 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7499 34 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7500 34 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7501 34 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7502 34 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7503 34 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7504 34 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7505 34 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7506 };
7507
7508 int32_t onScreenSaver()
7509 {
7510 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7511 int32_t oldcfgs[3];
7512 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7513 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7514 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7515
7516 large_dialog(scrsaver_dlg);
7517
7518 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7519
7520 if(ret == 8 || ret == 9)
7521 {
7522 ss_after = scrsaver_dlg[5].d1;
7523 ss_speed = scrsaver_dlg[6].d2;
7524 ss_density = scrsaver_dlg[7].d2;
7525 if(oldcfgs[0] != ss_after)
7526 zc_set_config(cfg_sect,"ss_after",ss_after);
7527 if(oldcfgs[1] != ss_speed)
7528 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7529 if(oldcfgs[2] != ss_density)
7530 zc_set_config(cfg_sect,"ss_density",ss_density);
7531 }
7532
7533 if(ret == 9)
7534 // preview Screen Saver
7535 {
7536 clear_keybuf();
7537 Matrix(ss_speed, ss_density, 30);
7538 system_pal();
7539 }
7540
7541 return D_O_K;
7542 }
7543
7544 /***** Menus *****/
7545
7546 static MENU game_menu[] =
7547 {
7548 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7549 { (char *)"", NULL, NULL, 0, NULL },
7550 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7551 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7552 { (char *)"", NULL, NULL, 0, NULL },
7553 #ifdef __EMSCRIPTEN__
7554 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7555 #elif defined(ALLEGRO_MACOSX)
7556 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7557 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7558 #else
7559 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7560 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7561 #endif
7562 { NULL, NULL, NULL, 0, NULL }
7563 };
7564
7565 static MENU title_menu[] =
7566 {
7567 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7568 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7569 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7570 { NULL, NULL, NULL, 0, NULL }
7571 };
7572
7573 static MENU snapshot_format_menu[] =
7574 {
7575 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7576 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7577 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7578 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7579 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7580 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7581 { NULL, NULL, NULL, 0, NULL }
7582 };
7583
7584 static MENU controls_menu[] =
7585 {
7586 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7587 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7588 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7589 { NULL, NULL, NULL, 0, NULL }
7590 };
7591
7592 static MENU name_entry_mode_menu[] =
7593 {
7594 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7595 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7596 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7597 { NULL, NULL, NULL, 0, NULL }
7598 };
7599
7600 static void set_controls_menu_active()
7601 {
7602
7603 }
7604
7605 static MENU window_menu[] =
7606 {
7607 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7608 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7609 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7610 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7611 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7612 { NULL, NULL, NULL, 0, NULL }
7613 };
7614 static MENU options_menu[] =
7615 {
7616 { "&Title Screen", NULL, title_menu, 0, NULL },
7617 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7618 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7619 { "&Window Settings", NULL, window_menu, 0, NULL },
7620 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7621 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7622 { NULL, NULL, NULL, 0, NULL }
7623 };
7624 static MENU settings_menu[] =
7625 {
7626 { "&Sound...", onSound, NULL, 0, NULL },
7627 { "C&ontrols", NULL, controls_menu, 0, NULL },
7628 { "", NULL, NULL, 0, NULL },
7629 { "Options", NULL, options_menu, 0, NULL },
7630 { "", NULL, NULL, 0, NULL },
7631 //
7632 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7633 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7634 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7635 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7636 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7637 //
7638 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7639 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7640 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7641 { "", NULL, NULL, 0, NULL },
7642 { "Debu&g", onDebug, NULL, 0, NULL },
7643 //
7644 { NULL, NULL, NULL, 0, NULL }
7645 };
7646
7647
7648 static MENU misc_menu[] =
7649 {
7650 { (char *)"&About...", onAbout, NULL, 0, NULL },
7651 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7652 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7653 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7654 { (char *)"", NULL, NULL, 0, NULL },
7655 //5
7656 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7657 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7658 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7659 { (char *)"", NULL, NULL, 0, NULL },
7660 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7661 //10
7662 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7663 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7664 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7665 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7666 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7667 //15
7668 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7669 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7670 { NULL, NULL, NULL, 0, NULL }
7671 };
7672
7673 static MENU refill_menu[] =
7674 {
7675 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7676 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7677 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7678 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7679 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7680 { NULL, NULL, NULL, 0, NULL }
7681 };
7682
7683 static MENU show_menu[] =
7684 {
7685 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7686 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7687 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7688 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7689 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7690 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7691 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7692 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7693 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7694 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7695 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7696 { (char *)"", NULL, NULL, 0, NULL },
7697 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7698 { (char *)"", NULL, NULL, 0, NULL },
7699 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7700 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7701 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7702 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7703 { NULL, NULL, NULL, 0, NULL }
7704 };
7705
7706 static MENU cheat_menu[] =
7707 {
7708 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7709 { (char *)"", NULL, NULL, 0, NULL },
7710 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7711 { (char *)"", NULL, NULL, 0, NULL },
7712 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7713 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7714 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7715 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7716 { (char *)"", NULL, NULL, 0, NULL },
7717 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7718 { (char *)"", NULL, NULL, 0, NULL },
7719 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7720 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7721 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7722 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7723 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7724 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7725 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7726 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7727 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7728 { NULL, NULL, NULL, 0, NULL }
7729 };
7730
7731 #if DEVLEVEL > 0
7732 int32_t devLogging();
7733 int32_t devDebug();
7734 int32_t devTimestmp();
7735 #if DEVLEVEL > 1
7736 int32_t setCheat();
7737 #endif //DEVLEVEL > 1
7738 enum
7739 {
7740 dv_log,
7741 // dv_dbg,
7742 dv_tmpstmp,
7743 #if DEVLEVEL > 1
7744 dv_nil,
7745 dv_setcheat,
7746 #endif //DEVLEVEL > 1
7747 dv_max
7748 };
7749 static MENU dev_menu[] =
7750 {
7751 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7752 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7753 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7754 #if DEVLEVEL > 1
7755 { (char *)"", NULL, NULL, 0, NULL },
7756 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7757 #endif //DEVLEVEL > 1
7758 { NULL, NULL, NULL, 0, NULL }
7759 };
7760 int32_t devLogging()
7761 {
7762 dev_logging = !dev_logging;
7763 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7764 return D_O_K;
7765 }
7766 // int32_t devDebug()
7767 // {
7768 // dev_debug = !dev_debug;
7769 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7770 // return D_O_K;
7771 // }
7772 int32_t devTimestmp()
7773 {
7774 dev_timestmp = !dev_timestmp;
7775 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7776 return D_O_K;
7777 }
7778 #if DEVLEVEL > 1
7779 int32_t setCheat()
7780 {
7781 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7782 return D_O_K;
7783 }
7784 #endif //DEVLEVEL > 1
7785 #endif //DEVLEVEL > 0
7786
7787 MENU the_player_menu[] =
7788 {
7789 { (char *)"&Game", NULL, game_menu, 0, NULL },
7790 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7791 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7792 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7793 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7794 #if DEVLEVEL > 0
7795 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7796 #endif
7797 { NULL, NULL, NULL, 0, NULL }
7798 };
7799 int32_t onMIDIPatch()
7800 {
7801 if(jwin_alert3(
7802 "Toggle Windows MIDI Fix",
7803 "This action will change whether ZC Player auto-restarts a MIDI at its",
7804 "last index if you move ZC Player out of focus, then back into focus.",
7805 "Proceed?",
7806 "&Yes",
7807 "&No",
7808 NULL,
7809 'y',
7810 'n',
7811 0,
7812 get_zc_font(font_lfont)) == 1)
7813 {
7814 midi_patch_fix = midi_patch_fix ? 0 : 1;
7815 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7816 }
7817 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7818 return D_O_K;
7819 }
7820
7821 int32_t onKeyboardEntry()
7822 {
7823 NameEntryMode=0;
7824 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7825 return D_O_K;
7826 }
7827
7828 int32_t onLetterGridEntry()
7829 {
7830 NameEntryMode=1;
7831 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7832 return D_O_K;
7833 }
7834
7835 int32_t onExtLetterGridEntry()
7836 {
7837 NameEntryMode=2;
7838 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7839 return D_O_K;
7840 }
7841
7842 static BITMAP* oldscreen;
7843 int32_t onFullscreenMenu()
7844 {
7845 // super hacks
7846 screen = oldscreen;
7847 if (onFullscreen() == D_REDRAW)
7848 {
7849 oldscreen = screen;
7850 }
7851 screen = menu_bmp;
7852 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7853 return D_O_K;
7854 }
7855
7856 34 void fix_menu()
7857 {
7858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 if(!debug_enabled)
7859 34 settings_menu[13].text = NULL;
7860 34 }
7861
7862 static DIALOG system_dlg[] =
7863 {
7864 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7865 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7866 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7867 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7868 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7869 #ifndef ALLEGRO_MACOSX
7870 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7871 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7872 #else
7873 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7874 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7875 #endif
7876 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7877 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7878 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7879 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7880 };
7881
7882 void reset_snapshot_format_menu()
7883 {
7884 for(int32_t i=0; i<ssfmtMAX; ++i)
7885 {
7886 snapshot_format_menu[i].flags=0;
7887 }
7888 }
7889
7890 int32_t onSetSnapshotFormat()
7891 {
7892 switch(active_menu->text[1])
7893 {
7894 case 'B': //"&BMP"
7895 SnapshotFormat=0;
7896 break;
7897
7898 case 'G': //"&GIF"
7899 SnapshotFormat=1;
7900 break;
7901
7902 case 'J': //"&JPG"
7903 SnapshotFormat=2;
7904 break;
7905
7906 case 'P': //"&PNG"
7907 SnapshotFormat=3;
7908 break;
7909
7910 case 'C': //"PC&X"
7911 SnapshotFormat=4;
7912 break;
7913
7914 case 'T': //"&TGA"
7915 SnapshotFormat=5;
7916 break;
7917
7918 case 'L': //"&LBM"
7919 SnapshotFormat=6;
7920 break;
7921 }
7922 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7923
7924 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7925 return D_O_K;
7926 }
7927
7928
7929 48 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7930 {
7931 PALETTE tmp;
7932
7933
2/2
✓ Branch 0 taken 12288 times.
✓ Branch 1 taken 48 times.
12336 for(int32_t i=0; i<256; i++)
7934 {
7935 12288 tmp[i].r=r;
7936 12288 tmp[i].g=g;
7937 12288 tmp[i].b=b;
7938 12288 }
7939
7940 48 fade_interpolate(src,tmp,dest,pos,from,to);
7941 48 }
7942
7943 48 void system_pal()
7944 {
7945 48 is_sys_pal = true;
7946 static PALETTE pal;
7947 48 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7948
7949 // set up the grayscale palette
7950
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 48 times.
3120 for(int32_t i=128; i<192; i++)
7951 {
7952 3072 pal[i].r = i-128;
7953 3072 pal[i].g = i-128;
7954 3072 pal[i].b = i-128;
7955 3072 }
7956 48 load_colorset(gui_colorset, pal, jwin_a5_colors);
7957
7958 48 color_layer(pal, pal, 24,16,16, 28, 128,191);
7959
7960
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 48 times.
6192 for(int32_t i=0; i<256; i+=2)
7961 {
7962 6144 int32_t v = (i>>3)+2;
7963 6144 int32_t c = (i>>3)+192;
7964 6144 pal[c] = _RGB(v,v,v+(v>>1));
7965 /*
7966 if(i<240)
7967 {
7968 _allegro_hline(tmp_scr,0,i,319,c);
7969 _allegro_hline(tmp_scr,0,i+1,319,c);
7970 }
7971 */
7972 6144 }
7973
7974 // draw the vertical screen gradient
7975
2/2
✓ Branch 0 taken 11520 times.
✓ Branch 1 taken 48 times.
11568 for(int32_t i=0; i<240; ++i)
7976 {
7977 11520 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7978 11520 }
7979
7980 /*
7981 palrstart= 10*63/255; palrend=166*63/255;
7982 palgstart= 36*63/255; palgend=202*63/255;
7983 palbstart=106*63/255; palbend=240*63/255;
7984 paldivs=32;
7985 for(int32_t i=0; i<paldivs; i++)
7986 {
7987 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7988 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7989 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7990 }
7991 */
7992 48 BITMAP *panorama = create_bitmap_ex(8,256,224);
7993 int32_t ts_height, ts_start;
7994
7995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7996 {
7997 clear_to_color(panorama,0);
7998 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7999 ts_height=224-passive_subscreen_height;
8000 ts_start=28;
8001 }
8002 else
8003 {
8004 48 blit(framebuf,panorama,0,0,0,0,256,224);
8005 48 ts_height=224;
8006 48 ts_start=0;
8007 }
8008
8009 // gray scale the current frame
8010
2/2
✓ Branch 0 taken 10752 times.
✓ Branch 1 taken 48 times.
10800 for(int32_t y=0; y<ts_height; y++)
8011 {
8012
2/2
✓ Branch 0 taken 2752512 times.
✓ Branch 1 taken 10752 times.
2763264 for(int32_t x=0; x<256; x++)
8013 {
8014 2752512 int32_t c = panorama->line[y+ts_start][x];
8015
2/2
✓ Branch 0 taken 2746589 times.
✓ Branch 1 taken 5923 times.
2752512 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8016 2752512 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8017 2752512 }
8018 10752 }
8019
8020 48 destroy_bitmap(panorama);
8021
8022 // display everything
8023 48 vsync();
8024 48 hw_palette = &pal;
8025 48 update_hw_pal = true;
8026
8027 // sys_pal = pal;
8028 48 memcpy(sys_pal,pal,sizeof(pal));
8029 48 }
8030
8031 void system_pal2()
8032 {
8033 is_sys_pal = true;
8034 static PALETTE RAMpal2;
8035 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8036
8037 /* Windows 2000 colors
8038 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8039 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8040 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8041 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8042 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8043 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8044 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8045 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8046
8047 byte palrstart= 10*63/255, palrend=166*63/255,
8048 palgstart= 36*63/255, palgend=202*63/255,
8049 palbstart=106*63/255, palbend=240*63/255,
8050 paldivs=7;
8051 for(int32_t i=0; i<paldivs; i++)
8052 {
8053 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8054 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8055 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8056 }
8057 */
8058
8059 /* Windows 98 colors
8060 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8061 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8062 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8063 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8064 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8065 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8066 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8067 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8068
8069 byte palrstart= 0*63/255, palrend=166*63/255,
8070 palgstart= 0*63/255, palgend=202*63/255,
8071 palbstart=128*63/255, palbend=240*63/255,
8072 paldivs=7;
8073 for(int32_t i=0; i<paldivs; i++)
8074 {
8075 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8076 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8077 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8078 }
8079 */
8080
8081 /* Windows 99 colors
8082 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8083 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8084 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8085 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8086 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8087 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8088 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8089 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8090 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8091
8092 byte palrstart= 0*63/255, palrend=166*63/255,
8093 palgstart= 0*63/255, palgend=202*63/255,
8094
8095 palbstart=128*63/255, palbend=240*63/255,
8096 paldivs=6;
8097 for(int32_t i=0; i<paldivs; i++)
8098 {
8099 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8100 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8101 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8102 }
8103 */
8104
8105
8106
8107 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8108 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8109 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8110 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8111 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8112 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8113 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8114 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8115 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8116
8117 byte palrstart= 0*63/255, palrend=166*63/255,
8118 palgstart= 0*63/255, palgend=202*63/255,
8119 palbstart=128*63/255, palbend=240*63/255,
8120 paldivs=6;
8121
8122 for(int32_t i=0; i<paldivs; i++)
8123 {
8124 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8125 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8126 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8127 }
8128
8129 gui_bg_color=jwin_pal[jcBOX];
8130 gui_fg_color=jwin_pal[jcBOXFG];
8131
8132 jwin_set_colors(jwin_pal);
8133
8134
8135 // set up the new palette
8136 for(int32_t i=128; i<192; i++)
8137 {
8138 RAMpal2[i].r = i-128;
8139 RAMpal2[i].g = i-128;
8140 RAMpal2[i].b = i-128;
8141 }
8142
8143 /*
8144 for(int32_t i=0; i<64; i++)
8145 {
8146 RAMpal2[128+i] = _RGB(i,i,i)1));
8147 }
8148 */
8149
8150 /*
8151
8152 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8153 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8154 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8155 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8156 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8157 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8158 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8159
8160 gui_fg_color=vc(14);
8161 gui_bg_color=vc(1);
8162
8163 jwin_set_colors(jwin_pal);
8164 */
8165
8166 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8167
8168 // set up the colors for the vertical screen gradient
8169 for(int32_t i=0; i<256; i+=2)
8170 {
8171 int32_t v = (i>>3)+2;
8172 int32_t c = (i>>3)+192;
8173 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8174
8175 /*
8176 if(i<240)
8177 {
8178 _allegro_hline(tmp_scr,0,i,319,c);
8179 _allegro_hline(tmp_scr,0,i+1,319,c);
8180 }
8181 */
8182 }
8183
8184 // hw_palette = &RAMpal;
8185 // update_hw_pal = true;
8186
8187 for(int32_t i=0; i<240; ++i)
8188 {
8189 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8190 }
8191
8192 /*
8193 byte palrstart= 10*63/255, palrend=166*63/255,
8194 palgstart= 36*63/255, palgend=202*63/255,
8195 palbstart=106*63/255, palbend=240*63/255,
8196 paldivs=32;
8197 for(int32_t i=0; i<paldivs; i++)
8198 {
8199 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8200 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8201 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8202 }
8203 */
8204 BITMAP *panorama = create_bitmap_ex(8,256,224);
8205 int32_t ts_height, ts_start;
8206
8207 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8208 {
8209 clear_to_color(panorama,0);
8210 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8211 ts_height=224-passive_subscreen_height;
8212 ts_start=28;
8213 }
8214 else
8215 {
8216 blit(framebuf,panorama,0,0,0,0,256,224);
8217 ts_height=224;
8218 ts_start=0;
8219 }
8220
8221 // gray scale the current frame
8222 for(int32_t y=0; y<ts_height; y++)
8223 {
8224 for(int32_t x=0; x<256; x++)
8225 {
8226 int32_t c = panorama->line[y+ts_start][x];
8227 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8228 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8229 }
8230 }
8231
8232 destroy_bitmap(panorama);
8233
8234 // display everything
8235 vsync();
8236 hw_palette = &RAMpal2;
8237 update_hw_pal = true;
8238
8239 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8240
8241 // sys_pal = pal;
8242 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8243 }
8244
8245 static uint32_t entered_sys_pal = 0;
8246 14 void enter_sys_pal()
8247 {
8248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8249 {
8250 if(entered_sys_pal)
8251 ++entered_sys_pal;
8252 return;
8253 }
8254 14 sys_mouse();
8255 14 system_pal();
8256 14 ++entered_sys_pal;
8257 14 }
8258 14 void exit_sys_pal()
8259 {
8260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8261 {
8262
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8263 {
8264 14 game_pal();
8265 14 game_mouse();
8266 14 }
8267 14 }
8268 14 }
8269
8270 void switch_out_callback()
8271 {
8272 if (pause_in_background)
8273 {
8274 callback_switchin = 3;
8275 return;
8276 }
8277
8278 #ifdef _WIN32
8279 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
8280 return;
8281
8282
8283 paused_midi_pos = midi_pos;
8284 zc_stop_midi();
8285 midi_paused=true;
8286 midi_suspended = midissuspHALTED;
8287 #endif
8288 }
8289
8290 void switch_in_callback()
8291 {
8292 if(pause_in_background)
8293 {
8294 return;
8295 }
8296
8297 #ifdef _WIN32
8298 if(midi_patch_fix==0 || currmidi==-1 || zcmusic)
8299 return;
8300
8301 else
8302 {
8303 callback_switchin = 1;
8304 midi_suspended = midissuspRESUME;
8305 }
8306 #endif
8307 }
8308
8309 344 void game_pal()
8310 {
8311 344 is_sys_pal = false;
8312 344 entered_sys_pal = 0;
8313 344 clear_to_color(screen,BLACK);
8314 344 hw_palette = &RAMpal;
8315 344 update_hw_pal = true;
8316 344 }
8317
8318 static char bar_str[] = "";
8319
8320 14 void music_pause()
8321 {
8322 //al_pause_duh(tmplayer);
8323 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8324 14 zc_midi_pause();
8325 14 midi_paused=true;
8326 14 }
8327
8328 void music_resume()
8329 {
8330 //al_resume_duh(tmplayer);
8331 zcmusic_pause(zcmusic, ZCM_RESUME);
8332 zc_midi_resume();
8333 midi_paused=false;
8334 }
8335
8336 6590 void music_stop()
8337 {
8338 //al_stop_duh(tmplayer);
8339 //unload_duh(tmusic);
8340 //tmusic=NULL;
8341 //tmplayer=NULL;
8342 6590 zcmusic_stop(zcmusic);
8343 6590 zcmusic_unload_file(zcmusic);
8344 6590 zc_stop_midi();
8345 6590 midi_paused=false;
8346 6590 currmidi=-1;
8347 6590 }
8348
8349 void System()
8350 {
8351 mouse_down=gui_mouse_b();
8352 music_pause();
8353 pause_all_sfx();
8354 MenuOpen = true;
8355 system_pal();
8356 // FONT *oldfont=font;
8357 // font=tfont;
8358
8359 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8360 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8361
8362 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8363 #if DEVLEVEL > 1
8364 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8365 #endif
8366 game_menu[3].flags =
8367 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8368 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8369 clear_keybuf();
8370 sys_mouse();
8371
8372 DIALOG_PLAYER *p;
8373
8374 clear_bitmap(menu_bmp);
8375 oldscreen = screen;
8376 screen = menu_bmp;
8377
8378 p = init_dialog(system_dlg,-1);
8379
8380 // drop the menu on startup if menu button pressed
8381 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8382 simulate_keypress(KEY_G << 8);
8383
8384 do
8385 {
8386 if(close_button_quit)
8387 {
8388 close_button_quit = false;
8389 f_Quit(qEXIT);
8390 if(Quit) break;
8391 }
8392 rest(17);
8393
8394 if(mouse_down && !gui_mouse_b())
8395 mouse_down=0;
8396
8397 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8398 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8399 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8400
8401 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8402 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8403 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8404 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8405 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8406 settings_menu[10].flags = NESquit?D_SELECTED:0;
8407 settings_menu[11].flags = volkeys?D_SELECTED:0;
8408
8409 window_menu[0].flags = DragAspect?D_SELECTED:0;
8410 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
8411 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
8412 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
8413 window_menu[4].flags = stretchGame?D_SELECTED:0;
8414
8415 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8416 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8417
8418 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8419 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8420 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8421
8422 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8423 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8424 misc_menu[14].flags =(clearConsoleOnReload)?D_SELECTED:0;
8425 misc_menu[15].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8426
8427 bool nocheat = (replay_is_replaying() || !Playing
8428 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
8429 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8430 cheat_menu[0].flags = 0;
8431 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8432 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8433 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8434 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8435 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8436 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8437 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8438 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8439 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8440
8441 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8442 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8443 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8444 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8445 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8446 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8447 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8448 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8449 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8450 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8451 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8452 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8453 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8454 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8455 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8456
8457 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8458 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8459
8460 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8461 (char *)"Disable recording new saves" :
8462 (char *)"Enable recording new saves";
8463 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8464 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8465 (char *)"Stop recording" :
8466 (char *)"Stop replaying";
8467 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8468 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8469 (char *)"Disable snapshot all frames" :
8470 (char *)"Enable snapshot all frames";
8471
8472 reset_snapshot_format_menu();
8473 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8474
8475 if(debug_enabled)
8476 {
8477 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8478 }
8479
8480 if(gui_mouse_b() && !mouse_down)
8481 break;
8482
8483 // press menu to drop the menu
8484 if(rMbtn())
8485 simulate_keypress(KEY_G << 8);
8486
8487 if(input_idle(true) > after_time())
8488 // run Screeen Saver
8489 {
8490 // Screen saver enabled for now.
8491 clear_keybuf();
8492 Matrix(ss_speed, ss_density, 0);
8493 system_pal();
8494 broadcast_dialog_message(MSG_DRAW, 0);
8495 }
8496
8497 update_hw_screen();
8498 }
8499 while(update_dialog(p));
8500
8501 screen = oldscreen;
8502
8503 // font=oldfont;
8504 mouse_down=gui_mouse_b();
8505 shutdown_dialog(p);
8506 game_mouse();
8507 MenuOpen = false;
8508 if(Quit)
8509 {
8510 kill_sfx();
8511 music_stop();
8512 update_hw_screen();
8513 }
8514 else
8515 {
8516 game_pal();
8517 music_resume();
8518 resume_all_sfx();
8519
8520 if(rc)
8521 ringcolor(false);
8522 }
8523
8524 eat_buttons();
8525
8526 rc=false;
8527 clear_keybuf();
8528 // text_mode(0);
8529 }
8530
8531 34 void fix_dialogs()
8532 {
8533 34 jwin_center_dialog(about_dlg);
8534 34 jwin_center_dialog(gamepad_dlg);
8535 34 jwin_center_dialog(credits_dlg);
8536 34 jwin_center_dialog(gamemode_dlg);
8537 34 jwin_center_dialog(getnum_dlg);
8538 34 jwin_center_dialog(goto_dlg);
8539 34 jwin_center_dialog(keyboard_control_dlg);
8540 34 jwin_center_dialog(midi_dlg);
8541 34 jwin_center_dialog(quest_dlg);
8542 34 jwin_center_dialog(scrsaver_dlg);
8543 34 jwin_center_dialog(sound_dlg);
8544 34 jwin_center_dialog(triforce_dlg);
8545
8546 // digi_dp[1] += scrx;
8547 // digi_dp[2] += scry;
8548 // midi_dp[1] += scrx;
8549 // midi_dp[2] += scry;
8550 // pan_dp[1] += scrx;
8551 // pan_dp[2] += scry;
8552 // emus_dp[1] += scrx;
8553 // emus_dp[2] += scry;
8554 // buf_dp[1] += scrx;
8555 // buf_dp[2] += scry;
8556 // sfx_dp[1] += scrx;
8557 // sfx_dp[2] += scry;
8558 34 }
8559
8560 /*****************************/
8561 /**** Custom Sound System ****/
8562 /*****************************/
8563
8564 2894 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8565 {
8566
3/4
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 258 times.
✓ Branch 2 taken 2894 times.
✗ Branch 3 not taken.
2894 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8567 }
8568
8569 // Run an NSF, or a MIDI if the NSF is missing somehow.
8570 106 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8571 {
8572 106 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8573
8574 // Found it
8575
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 38 times.
106 if(newzcmusic!=NULL)
8576 {
8577 68 zcmusic_stop(zcmusic);
8578 68 zcmusic_unload_file(zcmusic);
8579 68 zc_stop_midi();
8580
8581 68 zcmusic=newzcmusic;
8582 68 zcmusic_play(zcmusic, emusic_volume);
8583
8584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(track>0)
8585 68 zcmusic_change_track(zcmusic,track);
8586
8587 68 return true;
8588 }
8589
8590 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8591
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 else if(midi>-1000)
8592 jukebox(midi);
8593
8594 38 return false;
8595 106 }
8596
8597 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8598 {
8599 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8600 // Found it
8601 if(newzcmusic!=NULL)
8602 {
8603 zcmusic_stop(zcmusic);
8604 zcmusic_unload_file(zcmusic);
8605 zc_stop_midi();
8606
8607 zcmusic=newzcmusic;
8608 zcmusic_play(zcmusic, emusic_volume);
8609
8610 if(track>0)
8611 zcmusic_change_track(zcmusic,track);
8612
8613 return true;
8614 }
8615
8616 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8617 else if(midi>-1000)
8618 jukebox(midi);
8619
8620 return false;
8621 }
8622
8623 int32_t get_zcmusicpos()
8624 {
8625 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8626 return debugtracething;
8627 return 0;
8628 }
8629
8630 void set_zcmusicpos(int32_t position)
8631 {
8632 zcmusic_set_curpos(zcmusic, position);
8633 }
8634
8635 void set_zcmusicspeed(int32_t speed)
8636 {
8637 int32_t newspeed = vbound(speed, 0, 10000);
8638 zcmusic_set_speed(zcmusic, newspeed);
8639 }
8640
8641 1430 void jukebox(int32_t index,int32_t loop)
8642 {
8643 1430 music_stop();
8644
8645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(index<0) index=MAXMIDIS-1;
8646
8647
1/2
✓ Branch 0 taken 1430 times.
✗ Branch 1 not taken.
1430 if(index>=MAXMIDIS) index=0;
8648
8649 1430 music_stop();
8650
8651 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8652 // stuck notes when a song stops. This fixes it.
8653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1430 times.
1430 if(strcmp(midi_driver->name, "DIGMID")==0)
8654 zc_set_volume(0, 0);
8655
8656 1430 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8657 1430 zc_play_midi((MIDI*)tunes[index].data,loop);
8658
8659
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 402 times.
1430 if(tunes[index].start>0)
8660 402 zc_midi_seek(tunes[index].start);
8661
8662 1430 midi_loop_start = tunes[index].loop_start;
8663 1430 midi_loop_end = tunes[index].loop_end;
8664
8665 1430 currmidi=index;
8666 1430 master_volume(digi_volume,midi_volume);
8667 1430 midi_paused=false;
8668 1430 }
8669
8670 11423 void jukebox(int32_t index)
8671 {
8672
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index<0) index=MAXMIDIS-1;
8673
8674
1/2
✓ Branch 0 taken 11423 times.
✗ Branch 1 not taken.
11423 if(index>=MAXMIDIS) index=0;
8675
8676 // do nothing if it's already playing
8677
3/4
✓ Branch 0 taken 9993 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 9993 times.
✗ Branch 3 not taken.
11423 if(index==currmidi && midi_pos>=0)
8678 {
8679 9993 midi_paused=false;
8680 9993 return;
8681 }
8682
8683 1430 jukebox(index,tunes[index].loop);
8684 11423 }
8685
8686 12754 void play_DmapMusic()
8687 {
8688 static char tfile[2048];
8689 static int32_t ttrack=0;
8690 12754 bool domidi=false;
8691
8692
2/2
✓ Branch 0 taken 1455 times.
✓ Branch 1 taken 11299 times.
12754 if(DMaps[currdmap].tmusic[0]!=0)
8693 {
8694
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1070 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1840 if(zcmusic==NULL ||
8695
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8696
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8697 {
8698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1070 times.
1070 if(zcmusic != NULL)
8699 {
8700 zcmusic_stop(zcmusic);
8701 zcmusic_unload_file(zcmusic);
8702 zcmusic = NULL;
8703 }
8704
8705 1070 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8706
8707
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 983 times.
1070 if(zcmusic!=NULL)
8708 {
8709 87 zc_stop_midi();
8710 87 strcpy(tfile,DMaps[currdmap].tmusic);
8711 87 zcmusic_play(zcmusic, emusic_volume);
8712 87 int32_t temptracks=0;
8713 87 temptracks=zcmusic_get_tracks(zcmusic);
8714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 temptracks=(temptracks<2)?1:temptracks;
8715 87 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8716 87 zcmusic_change_track(zcmusic,ttrack);
8717 87 }
8718 else
8719 {
8720 983 tfile[0] = 0;
8721 983 domidi=true;
8722 }
8723 1070 }
8724 1455 }
8725 else
8726 {
8727 11299 domidi=true;
8728 }
8729
8730
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 12282 times.
12754 if(domidi)
8731 {
8732 12282 int32_t m=DMaps[currdmap].midi;
8733
8734
3/4
✓ Branch 0 taken 11875 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
12282 switch(m)
8735 {
8736 case 1:
8737 368 jukebox(ZC_MIDI_OVERWORLD);
8738 368 break;
8739
8740 case 2:
8741 39 jukebox(ZC_MIDI_DUNGEON);
8742 39 break;
8743
8744 case 3:
8745 jukebox(ZC_MIDI_LEVEL9);
8746 break;
8747
8748 default:
8749
3/4
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10843 times.
11875 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8750 10843 jukebox(m+MIDIOFFSET_DMAP);
8751 else
8752 1032 music_stop();
8753 11875 }
8754 12282 }
8755 12754 }
8756
8757 12792 void playLevelMusic()
8758 {
8759 12792 int32_t m=tmpscr->screen_midi;
8760
8761
3/6
✓ Branch 0 taken 12738 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
12792 switch(m)
8762 {
8763 case -2:
8764 13 music_stop();
8765 13 break;
8766
8767 case -1:
8768 12738 play_DmapMusic();
8769 12738 break;
8770
8771 case 1:
8772 jukebox(ZC_MIDI_OVERWORLD);
8773 break;
8774
8775 case 2:
8776 jukebox(ZC_MIDI_DUNGEON);
8777 break;
8778
8779 case 3:
8780 jukebox(ZC_MIDI_LEVEL9);
8781 break;
8782
8783 default:
8784
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8785 41 jukebox(m+MIDIOFFSET_MAPSCR);
8786 else
8787 music_stop();
8788 41 }
8789 12792 }
8790
8791 1464 void master_volume(int32_t dv,int32_t mv)
8792 {
8793
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1464 times.
✓ Branch 2 taken 1464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1464 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1464 times.
✗ Branch 7 not taken.
1464 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8794
8795
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1464 times.
✓ Branch 2 taken 1464 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1464 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1464 times.
✗ Branch 7 not taken.
1464 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8796
8797
6/6
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 1462 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1423 times.
✓ Branch 5 taken 39 times.
1464 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8798 1464 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8799 1464 }
8800
8801 /*****************/
8802 /***** SFX *****/
8803 /*****************/
8804
8805 // array of voices, one for each sfx sample in the data file
8806 // 0+ = voice #
8807 // -1 = voice not allocated
8808 34 void Z_init_sound()
8809 {
8810
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 34 times.
8738 for(int32_t i=0; i<WAV_COUNT; i++)
8811 8704 sfx_voice[i]=-1;
8812
8813
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 34 times.
272 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8814 238 tunes[i].data = (MIDI*)mididata[i].dat;
8815
8816
2/2
✓ Branch 0 taken 8568 times.
✓ Branch 1 taken 34 times.
8602 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8817 8568 tunes[ZC_MIDI_COUNT+j].data=NULL;
8818
8819 34 master_volume(digi_volume,midi_volume);
8820 34 }
8821
8822 // returns number of voices currently allocated
8823 int32_t sfx_count()
8824 {
8825 int32_t c=0;
8826
8827 for(int32_t i=0; i<WAV_COUNT; i++)
8828 if(sfx_voice[i]!=-1)
8829 ++c;
8830
8831 return c;
8832 }
8833
8834 // clean up finished samples
8835 8090150 void sfx_cleanup()
8836 {
8837
2/2
✓ Branch 0 taken 2071078400 times.
✓ Branch 1 taken 8090150 times.
2079168550 for(int32_t i=0; i<WAV_COUNT; i++)
8838
3/4
✓ Branch 0 taken 634457 times.
✓ Branch 1 taken 2070443943 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 634457 times.
2071712857 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8839 {
8840 634457 deallocate_voice(sfx_voice[i]);
8841 634457 sfx_voice[i]=-1;
8842 634457 }
8843 8090150 }
8844
8845 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8846 // if a voice is already allocated (and/or playing), then it just returns true
8847 // Returns true: voice is allocated
8848 // false: unsuccessful
8849 974664 bool sfx_init(int32_t index)
8850 {
8851 // check index
8852
3/4
✓ Branch 0 taken 703378 times.
✓ Branch 1 taken 271286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 703378 times.
974664 if(index<=0 || index>=WAV_COUNT)
8853 271286 return false;
8854
8855
2/2
✓ Branch 0 taken 68894 times.
✓ Branch 1 taken 634484 times.
703378 if(sfx_voice[index]==-1)
8856 {
8857
2/2
✓ Branch 0 taken 182177 times.
✓ Branch 1 taken 452307 times.
634484 if(sfxdat)
8858 {
8859
1/2
✓ Branch 0 taken 182177 times.
✗ Branch 1 not taken.
182177 if(index<Z35)
8860 {
8861 182177 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8862 182177 }
8863 else
8864 {
8865 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8866 }
8867 182177 }
8868 else
8869 {
8870 452307 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8871 }
8872
8873 634484 voice_set_volume(sfx_voice[index], sfx_volume);
8874 634484 }
8875
8876 703378 return sfx_voice[index] != -1;
8877 974664 }
8878
8879 // plays an sfx sample
8880 829484 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8881 {
8882
2/2
✓ Branch 0 taken 630973 times.
✓ Branch 1 taken 198511 times.
829484 if(!sfx_init(index))
8883 198511 return;
8884
8885 630973 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8886 630973 voice_set_pan(sfx_voice[index],pan);
8887
8888 630973 int32_t pos = voice_get_position(sfx_voice[index]);
8889
8890
2/2
✓ Branch 0 taken 298046 times.
✓ Branch 1 taken 332927 times.
630973 if(restart) voice_set_position(sfx_voice[index],0);
8891
8892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630973 times.
630973 if(pos<=0)
8893 630973 voice_start(sfx_voice[index]);
8894
8895
3/4
✓ Branch 0 taken 332927 times.
✓ Branch 1 taken 298046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 332927 times.
630973 if (restart && replay_is_debug())
8896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332927 times.
332927 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8897 829484 }
8898
8899 // true if sfx is allocated
8900 35405 bool sfx_allocated(int32_t index)
8901 {
8902
3/4
✓ Branch 0 taken 9407 times.
✓ Branch 1 taken 25998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9407 times.
35405 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8903 }
8904
8905 // start it (in loop mode) if it's not already playing,
8906 // otherwise adjust it to play in loop mode -DD
8907 145180 void cont_sfx(int32_t index)
8908 {
8909
2/2
✓ Branch 0 taken 72775 times.
✓ Branch 1 taken 72405 times.
145180 if(!sfx_init(index))
8910 {
8911 72775 return;
8912 }
8913
8914
1/2
✓ Branch 0 taken 72405 times.
✗ Branch 1 not taken.
72405 if(voice_get_position(sfx_voice[index])<=0)
8915 {
8916 72405 voice_set_position(sfx_voice[index],0);
8917 72405 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8918 72405 voice_start(sfx_voice[index]);
8919 72405 }
8920 else
8921 {
8922 adjust_sfx(index, 128, true);
8923 }
8924 145180 }
8925
8926 // adjust parameters while playing
8927 3961 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8928 {
8929
5/6
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2187 times.
3961 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8930 3947 return;
8931
8932 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8933 14 voice_set_pan(sfx_voice[index],pan);
8934 3961 }
8935
8936 // pauses a voice
8937 1651 void pause_sfx(int32_t index)
8938 {
8939
3/6
✓ Branch 0 taken 1651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1651 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1651 times.
1651 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8940 voice_stop(sfx_voice[index]);
8941 1651 }
8942
8943 // resumes a voice
8944 709 void resume_sfx(int32_t index)
8945 {
8946
3/6
✓ Branch 0 taken 709 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 709 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 709 times.
709 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8947 voice_start(sfx_voice[index]);
8948 709 }
8949
8950 // pauses all active voices
8951 320 void pause_all_sfx()
8952 {
8953
2/2
✓ Branch 0 taken 81920 times.
✓ Branch 1 taken 320 times.
82240 for(int32_t i=0; i<WAV_COUNT; i++)
8954
2/2
✓ Branch 0 taken 81919 times.
✓ Branch 1 taken 1 times.
81921 if(sfx_voice[i]!=-1)
8955 1 voice_stop(sfx_voice[i]);
8956 320 }
8957
8958 // resumes all paused voices
8959 306 void resume_all_sfx()
8960 {
8961
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 306 times.
78642 for(int32_t i=0; i<WAV_COUNT; i++)
8962
1/2
✓ Branch 0 taken 78336 times.
✗ Branch 1 not taken.
78336 if(sfx_voice[i]!=-1)
8963 voice_start(sfx_voice[i]);
8964 306 }
8965
8966 // stops an sfx and deallocates the voice
8967 6474401 void stop_sfx(int32_t index)
8968 {
8969
3/4
✓ Branch 0 taken 5333200 times.
✓ Branch 1 taken 1141201 times.
✓ Branch 2 taken 5333200 times.
✗ Branch 3 not taken.
6474401 if(index<=0 || index>=WAV_COUNT)
8970 1141201 return;
8971
8972
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5333187 times.
5333200 if(sfx_voice[index]!=-1)
8973 {
8974 13 deallocate_voice(sfx_voice[index]);
8975 13 sfx_voice[index]=-1;
8976 13 }
8977 6474401 }
8978
8979 // Stops SFX played by Hero's item of the given family
8980 134717 void stop_item_sfx(int32_t family)
8981 {
8982 134717 int32_t id=current_item_id(family);
8983
8984
2/2
✓ Branch 0 taken 134251 times.
✓ Branch 1 taken 466 times.
134717 if(id<0)
8985 134251 return;
8986
8987 466 stop_sfx(itemsbuf[id].usesound);
8988 134717 }
8989
8990 2359 void kill_sfx()
8991 {
8992
2/2
✓ Branch 0 taken 603904 times.
✓ Branch 1 taken 2359 times.
606263 for(int32_t i=0; i<WAV_COUNT; i++)
8993
2/2
✓ Branch 0 taken 603890 times.
✓ Branch 1 taken 14 times.
603918 if(sfx_voice[i]!=-1)
8994 {
8995 14 deallocate_voice(sfx_voice[i]);
8996 14 sfx_voice[i]=-1;
8997 14 }
8998 2359 }
8999
9000 583542 int32_t pan(int32_t x)
9001 {
9002
1/4
✓ Branch 0 taken 583542 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
583542 switch(pan_style)
9003 {
9004 case 0:
9005 return 128;
9006
9007 case 1:
9008 583542 return vbound((x>>1)+68,0,255);
9009
9010 case 2:
9011 return vbound(((x*3)>>2)+36,0,255);
9012 }
9013
9014 return vbound(x,0,255);
9015 583542 }
9016
9017 /*******************************/
9018 /******* Input Handlers ********/
9019 /*******************************/
9020
9021 21833275 bool joybtn(int32_t b)
9022 {
9023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21833275 times.
21833275 if(b == 0)
9024 return false;
9025
9026 21833275 return joy[joystick_index].button[b-1].b !=0;
9027 21833275 }
9028
9029 const char* joybtn_name(int32_t b)
9030 {
9031 if(b == 0)
9032 return "";
9033
9034 return joy[joystick_index].button[b-1].name;
9035 }
9036
9037 int32_t next_press_key();
9038
9039 int32_t next_press_btn()
9040 {
9041 clear_keybuf();
9042 /*bool b[joy[joystick_index].num_buttons+1];
9043
9044 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9045 b[i]=joybtn(i);*/
9046
9047 //first, we need to wait until they're pressing no buttons
9048 for(;;)
9049 {
9050 if(keypressed())
9051 {
9052 switch(readkey()>>8)
9053 {
9054 case KEY_ESC:
9055 return -1;
9056
9057 case KEY_SPACE:
9058 return 0;
9059 }
9060 }
9061
9062 poll_joystick();
9063 bool done = true;
9064
9065 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9066 {
9067 if(joybtn(i)) done = false;
9068 }
9069
9070 if(done) break;
9071 rest(1);
9072 }
9073
9074 //now, we need to wait for them to press any button
9075 for(;;)
9076 {
9077 if(keypressed())
9078 {
9079 switch(readkey()>>8)
9080 {
9081 case KEY_ESC:
9082 return -1;
9083
9084 case KEY_SPACE:
9085 return 0;
9086 }
9087 }
9088
9089 poll_joystick();
9090
9091 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9092 {
9093 if(joybtn(i)) return i;
9094 }
9095 rest(1);
9096 }
9097 }
9098
9099 168596472 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9100 {
9101
2/2
✓ Branch 0 taken 162705230 times.
✓ Branch 1 taken 5891242 times.
168596472 bool ret = btn && !flag;
9102
2/2
✓ Branch 0 taken 142469327 times.
✓ Branch 1 taken 26127145 times.
168596472 flag = rawbtn ? *rawbtn : btn;
9103
9104 168596472 return ret;
9105 }
9106 1646643 static bool rButtonPeek(bool btn, bool flag)
9107 {
9108
2/2
✓ Branch 0 taken 1533938 times.
✓ Branch 1 taken 112705 times.
1646643 if(!btn)
9109 {
9110 1533938 return false;
9111 }
9112
2/2
✓ Branch 0 taken 16409 times.
✓ Branch 1 taken 96296 times.
112705 else if(!flag)
9113 {
9114 16409 return true;
9115 }
9116
9117 96296 return false;
9118 1646643 }
9119
9120 // Updated only by keyboard/gamepad.
9121 // If in replay mode, this is set directly by the replay system.
9122 // This should never be read from directly - use control_state instead.
9123 bool raw_control_state[ZC_CONTROL_STATES];
9124
9125 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9126 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9127 // lasts until the next call to load_control_state.
9128 bool control_state[ZC_CONTROL_STATES];
9129 bool disable_control[ZC_CONTROL_STATES];
9130 bool drunk_toggle_state[11];
9131 bool disabledKeys[127];
9132 bool KeyInput[127];
9133 bool KeyPress[127];
9134
9135 bool key_current_frame[127];
9136 bool key_previous_frame[127];
9137
9138 static bool key_system[127];
9139 static bool key_system_previous[127];
9140 static bool key_system_press[127];
9141
9142 bool button_press[ZC_CONTROL_STATES];
9143 bool button_hold[ZC_CONTROL_STATES];
9144
9145 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9146 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9147 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9148 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9149 #define STICK_PRECISION 56 //define your own sensitivity
9150
9151 6821319 void load_control_state()
9152 {
9153 6821319 load_control_called_this_frame = true;
9154
9155
4/4
✓ Branch 0 taken 3950118 times.
✓ Branch 1 taken 2871201 times.
✓ Branch 2 taken 1297366 times.
✓ Branch 3 taken 2652752 times.
6821319 if (replay_get_version() >= 8 && replay_get_version() < 11)
9156 {
9157
2/2
✓ Branch 0 taken 47749536 times.
✓ Branch 1 taken 2652752 times.
50402288 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9158 47749536 down_control_states[i] = raw_control_state[i];
9159 2652752 }
9160
9161
1/2
✓ Branch 0 taken 6821319 times.
✗ Branch 1 not taken.
6821319 if (!replay_is_replaying())
9162 {
9163 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9164 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9165 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9166 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9167 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9168 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9169 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9170 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9171 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9172 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9173 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9174 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9175 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9176 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9177
9178 if(num_joysticks != 0)
9179 {
9180 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9181 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9182 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9183 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9184 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9185 }
9186 else
9187 {
9188 raw_control_state[14] = false;
9189 raw_control_state[15] = false;
9190 raw_control_state[16] = false;
9191 raw_control_state[17] = false;
9192 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9193 }
9194 bool did_bad_cutscene_btn = false;
9195 for(int q = 0; q < 18; ++q)
9196 if(raw_control_state[q] && !active_cutscene.can_button(q))
9197 {
9198 raw_control_state[q] = false;
9199 did_bad_cutscene_btn = true;
9200 }
9201 if(did_bad_cutscene_btn)
9202 active_cutscene.error();
9203 }
9204
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6821316 times.
6821319 if (replay_is_active())
9205 {
9206
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 5806101 times.
6821316 if (replay_get_version() < 3)
9207 1015215 replay_poll();
9208
3/4
✓ Branch 0 taken 5806101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4044726 times.
✓ Branch 3 taken 1761375 times.
5806101 else if (replay_is_replaying() && replay_get_version() < 6)
9209 1761375 replay_peek_input();
9210
5/6
✓ Branch 0 taken 4044726 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3950118 times.
✓ Branch 3 taken 94608 times.
✓ Branch 4 taken 1297366 times.
✓ Branch 5 taken 2652752 times.
4044726 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9211 2652752 replay_peek_input();
9212
2/2
✓ Branch 0 taken 5716559 times.
✓ Branch 1 taken 1104757 times.
6821316 if (replay_get_version() == 8)
9213 1104757 update_keys();
9214 6821316 }
9215
9216 // Some test replay files were made before a serious input bug was fixed, so instead
9217 // of re-doing them or tossing them out, just check for that zplay version.
9218
3/4
✓ Branch 0 taken 6821313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 6699413 times.
6821319 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9219
2/2
✓ Branch 0 taken 122783634 times.
✓ Branch 1 taken 6821313 times.
129604947 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9220 {
9221 122783634 control_state[i] = raw_control_state[i];
9222
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 73296324 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
122783634 if (botched_input && !control_state[i])
9223 47077142 down_control_states[i] = false;
9224 122783634 }
9225
9226 6821313 button_press[0]=rButton(control_state[0],button_hold[0]);
9227 6821313 button_press[1]=rButton(control_state[1],button_hold[1]);
9228 6821313 button_press[2]=rButton(control_state[2],button_hold[2]);
9229 6821313 button_press[3]=rButton(control_state[3],button_hold[3]);
9230 6821313 button_press[4]=rButton(control_state[4],button_hold[4]);
9231 6821313 button_press[5]=rButton(control_state[5],button_hold[5]);
9232 6821313 button_press[6]=rButton(control_state[6],button_hold[6]);
9233 6821313 button_press[7]=rButton(control_state[7],button_hold[7]);
9234 6821313 button_press[8]=rButton(control_state[8],button_hold[8]);
9235 6821313 button_press[9]=rButton(control_state[9],button_hold[9]);
9236 6821313 button_press[10]=rButton(control_state[10],button_hold[10]);
9237 6821313 button_press[11]=rButton(control_state[11],button_hold[11]);
9238 6821313 button_press[12]=rButton(control_state[12],button_hold[12]);
9239 6821313 button_press[13]=rButton(control_state[13],button_hold[13]);
9240 6821313 button_press[14]=rButton(control_state[14],button_hold[14]);
9241 6821313 button_press[15]=rButton(control_state[15],button_hold[15]);
9242 6821313 button_press[16]=rButton(control_state[16],button_hold[16]);
9243 6821313 button_press[17]=rButton(control_state[17],button_hold[17]);
9244 6821313 }
9245
9246 // Returns true if any game key is pressed. This is needed because keypressed()
9247 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9248 35420436 bool zc_key_pressed()
9249 //may also need to use zc_getrawkey
9250 {
9251
7/10
✓ Branch 0 taken 28698700 times.
✓ Branch 1 taken 6721736 times.
✓ Branch 2 taken 6721736 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6721736 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5635742 times.
✓ Branch 7 taken 5635742 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2139285 times.
37559721 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9252
4/6
✓ Branch 0 taken 5635742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5635742 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4269605 times.
✓ Branch 5 taken 4269605 times.
5635742 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9253
4/6
✓ Branch 0 taken 4269605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4269605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2758689 times.
✓ Branch 5 taken 2758689 times.
4269605 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9254
4/6
✓ Branch 0 taken 2758689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2758689 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2392862 times.
✓ Branch 5 taken 2392862 times.
2758689 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9255
1/2
✓ Branch 0 taken 2392862 times.
✗ Branch 1 not taken.
2392862 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9256
3/4
✓ Branch 0 taken 2276894 times.
✓ Branch 1 taken 115968 times.
✓ Branch 2 taken 2276894 times.
✗ Branch 3 not taken.
2392862 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9257
3/4
✓ Branch 0 taken 2168977 times.
✓ Branch 1 taken 107917 times.
✓ Branch 2 taken 2168977 times.
✗ Branch 3 not taken.
2276894 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9258
3/4
✓ Branch 0 taken 2154486 times.
✓ Branch 1 taken 14491 times.
✓ Branch 2 taken 2154486 times.
✗ Branch 3 not taken.
2168977 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9259
3/4
✓ Branch 0 taken 2141908 times.
✓ Branch 1 taken 12578 times.
✓ Branch 2 taken 2141908 times.
✗ Branch 3 not taken.
2154486 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9260
3/4
✓ Branch 0 taken 2140164 times.
✓ Branch 1 taken 1744 times.
✓ Branch 2 taken 2140164 times.
✗ Branch 3 not taken.
2141908 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9261
3/4
✓ Branch 0 taken 2140091 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 2140091 times.
✗ Branch 3 not taken.
2140164 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9262
3/4
✓ Branch 0 taken 2139304 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 2139304 times.
✗ Branch 3 not taken.
2140091 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9263
2/4
✓ Branch 0 taken 2139304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2139304 times.
✗ Branch 3 not taken.
2139304 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9264
2/2
✓ Branch 0 taken 2139285 times.
✓ Branch 1 taken 19 times.
2139304 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9265 63394947 return true;
9266
9267 2139285 return false;
9268 8136832 }
9269
9270 133877900 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9271 {
9272 133877900 bool ret = false, drunkstate = false, rawret = false;
9273 133877900 bool* flag = &down_control_states[btn];
9274
2/7
✓ Branch 0 taken 125732574 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 8145326 times.
133877900 switch(btn)
9275 {
9276 case btnF12:
9277 ret = zc_getkey(KEY_F12, ignoreDisable);
9278 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9279 eatEntirely = false;
9280 break;
9281 case btnF11:
9282 ret = zc_getkey(KEY_F11, ignoreDisable);
9283 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9284 eatEntirely = false;
9285 break;
9286 case btnF5:
9287 ret = zc_getkey(KEY_F5, ignoreDisable);
9288 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9289 eatEntirely = false;
9290 break;
9291 case btnQ:
9292 ret = zc_getkey(KEY_Q, ignoreDisable);
9293 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9294 eatEntirely = false;
9295 break;
9296 case btnI:
9297 ret = zc_getkey(KEY_I, ignoreDisable);
9298 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9299 eatEntirely = false;
9300 break;
9301 case btnM:
9302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8145326 times.
8145326 if(FFCore.kb_typing_mode) return false;
9303 8145326 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9304 8145326 eatEntirely = false;
9305 8145326 break;
9306 default: //control_state[] index
9307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125732574 times.
125732574 if(FFCore.kb_typing_mode) return false;
9308
5/6
✓ Branch 0 taken 125259120 times.
✓ Branch 1 taken 473454 times.
✓ Branch 2 taken 2348400 times.
✓ Branch 3 taken 122910720 times.
✓ Branch 4 taken 2348400 times.
✗ Branch 5 not taken.
125732574 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9309
2/2
✓ Branch 0 taken 6791748 times.
✓ Branch 1 taken 118940826 times.
125732574 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9310
4/4
✓ Branch 0 taken 113328776 times.
✓ Branch 1 taken 12403798 times.
✓ Branch 2 taken 5048 times.
✓ Branch 3 taken 12398750 times.
138136372 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9311 125732574 rawret = raw_control_state[btn];
9312 125732574 }
9313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133877900 times.
133877900 assert(flag);
9314
2/2
✓ Branch 0 taken 86418419 times.
✓ Branch 1 taken 47459481 times.
133877900 if(press)
9315 {
9316
2/2
✓ Branch 0 taken 1646643 times.
✓ Branch 1 taken 45812838 times.
47459481 if(peek)
9317 1646643 ret = rButtonPeek(ret, *flag);
9318
3/4
✓ Branch 0 taken 45812838 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26127145 times.
✓ Branch 3 taken 19685693 times.
45812838 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9319 26127145 else ret = rButton(ret, *flag, &rawret);
9320 47459481 }
9321
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133877900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133877900 if(eatEntirely && ret) control_state[btn] = false;
9322
3/4
✓ Branch 0 taken 101239406 times.
✓ Branch 1 taken 32638494 times.
✓ Branch 2 taken 101239406 times.
✗ Branch 3 not taken.
133877900 if(drunk && drunkstate) ret = !ret;
9323 133877900 return ret;
9324 133877900 }
9325
9326 6589295 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9327 {
9328 6589295 byte ret = 0;
9329
2/2
✓ Branch 0 taken 4940574 times.
✓ Branch 1 taken 1648721 times.
6589295 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9330
2/2
✓ Branch 0 taken 6588733 times.
✓ Branch 1 taken 562 times.
6589295 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9331
2/2
✓ Branch 0 taken 6588858 times.
✓ Branch 1 taken 437 times.
6589295 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9332
2/2
✓ Branch 0 taken 6588858 times.
✓ Branch 1 taken 437 times.
6589295 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9333
2/2
✓ Branch 0 taken 6588858 times.
✓ Branch 1 taken 437 times.
6589295 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9334
2/2
✓ Branch 0 taken 6588858 times.
✓ Branch 1 taken 437 times.
6589295 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9335
2/2
✓ Branch 0 taken 6588858 times.
✓ Branch 1 taken 437 times.
6589295 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9336
2/2
✓ Branch 0 taken 6588858 times.
✓ Branch 1 taken 437 times.
6589295 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9337 6589295 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9338 }
9339
9340 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9341 {
9342 1114 return intbtn&vals;
9343 }
9344
9345 1579380 bool Up()
9346 {
9347 1579380 return getInput(btnUp);
9348 }
9349 100763 bool Down()
9350 {
9351 100763 return getInput(btnDown);
9352 }
9353 193222 bool Left()
9354 {
9355 193222 return getInput(btnLeft);
9356 }
9357 217697 bool Right()
9358 {
9359 217697 return getInput(btnRight);
9360 }
9361 112761 bool cAbtn()
9362 {
9363 112761 return getInput(btnA);
9364 }
9365 1333347 bool cBbtn()
9366 {
9367 1333347 return getInput(btnB);
9368 }
9369 bool cSbtn()
9370 {
9371 return getInput(btnS);
9372 }
9373 46682 bool cLbtn()
9374 {
9375 46682 return getInput(btnL);
9376 }
9377 46682 bool cRbtn()
9378 {
9379 46682 return getInput(btnR);
9380 }
9381 bool cPbtn()
9382 {
9383 return getInput(btnP);
9384 }
9385 bool cEx1btn()
9386 {
9387 return getInput(btnEx1);
9388 }
9389 bool cEx2btn()
9390 {
9391 return getInput(btnEx2);
9392 }
9393 bool cEx3btn()
9394 {
9395 return getInput(btnEx3);
9396 }
9397 bool cEx4btn()
9398 {
9399 return getInput(btnEx4);
9400 }
9401 bool AxisUp()
9402 {
9403 return getInput(btnAxisUp);
9404 }
9405 bool AxisDown()
9406 {
9407 return getInput(btnAxisDown);
9408 }
9409 bool AxisLeft()
9410 {
9411 return getInput(btnAxisLeft);
9412 }
9413 bool AxisRight()
9414 {
9415 return getInput(btnAxisRight);
9416 }
9417
9418 bool cMbtn()
9419 {
9420 return getInput(btnM);
9421 }
9422 bool cF12()
9423 {
9424 return getInput(btnF12);
9425 }
9426 bool cF11()
9427 {
9428 return getInput(btnF11);
9429 }
9430 bool cF5()
9431 {
9432 return getInput(btnF5);
9433 }
9434 bool cQ()
9435 {
9436 return getInput(btnQ);
9437 }
9438 bool cI()
9439 {
9440 return getInput(btnI);
9441 }
9442
9443 127703 bool rUp()
9444 {
9445 127703 return getInput(btnUp, true);
9446 }
9447 127609 bool rDown()
9448 {
9449 127609 return getInput(btnDown, true);
9450 }
9451 127557 bool rLeft()
9452 {
9453 127557 return getInput(btnLeft, true);
9454 }
9455 127093 bool rRight()
9456 {
9457 127093 return getInput(btnRight, true);
9458 }
9459 2987 bool rAbtn()
9460 {
9461 2987 return getInput(btnA, true);
9462 }
9463 128823 bool rBbtn()
9464 {
9465 128823 return getInput(btnB, true);
9466 }
9467 6548067 bool rSbtn()
9468 {
9469 6548067 return getInput(btnS, true);
9470 }
9471 8136832 bool rMbtn()
9472 {
9473 8136832 return getInput(btnM, true);
9474 }
9475 126885 bool rLbtn()
9476 {
9477 126885 return getInput(btnL, true);
9478 }
9479 126880 bool rRbtn()
9480 {
9481 126880 return getInput(btnR, true);
9482 }
9483 6465241 bool rPbtn()
9484 {
9485 6465241 return getInput(btnP, true);
9486 }
9487 bool rEx1btn()
9488 {
9489 return getInput(btnEx1, true);
9490 }
9491 bool rEx2btn()
9492 {
9493 return getInput(btnEx2, true);
9494 }
9495 137531 bool rEx3btn()
9496 {
9497 137531 return getInput(btnEx3, true);
9498 }
9499 137531 bool rEx4btn()
9500 {
9501 137531 return getInput(btnEx4, true);
9502 }
9503 bool rAxisUp()
9504 {
9505 return getInput(btnAxisUp, true);
9506 }
9507 bool rAxisDown()
9508 {
9509 return getInput(btnAxisDown, true);
9510 }
9511 bool rAxisLeft()
9512 {
9513 return getInput(btnAxisLeft, true);
9514 }
9515 bool rAxisRight()
9516 {
9517 return getInput(btnAxisRight, true);
9518 }
9519
9520 bool rF11()
9521 {
9522 return getInput(btnF11, true);
9523 }
9524 bool rQ()
9525 {
9526 return getInput(btnQ, true);
9527 }
9528 bool rI()
9529 {
9530 return getInput(btnI, true);
9531 }
9532
9533 16396385 bool DrunkUp()
9534 {
9535 16396385 return getInput(btnUp, false, true);
9536 }
9537 15269325 bool DrunkDown()
9538 {
9539 15269325 return getInput(btnDown, false, true);
9540 }
9541 9598897 bool DrunkLeft()
9542 {
9543 9598897 return getInput(btnLeft, false, true);
9544 }
9545 8332010 bool DrunkRight()
9546 {
9547 8332010 return getInput(btnRight, false, true);
9548 }
9549 7131764 bool DrunkcAbtn()
9550 {
9551 7131764 return getInput(btnA, false, true);
9552 }
9553 7017789 bool DrunkcBbtn()
9554 {
9555 7017789 return getInput(btnB, false, true);
9556 }
9557 6418211 bool DrunkcEx1btn()
9558 {
9559 6418211 return getInput(btnEx1, false, true);
9560 }
9561 6418231 bool DrunkcEx2btn()
9562 {
9563 6418231 return getInput(btnEx2, false, true);
9564 }
9565 bool DrunkcSbtn()
9566 {
9567 return getInput(btnS, false, true);
9568 }
9569 bool DrunkcMbtn()
9570 {
9571 return getInput(btnM, false, true);
9572 }
9573 bool DrunkcLbtn()
9574 {
9575 return getInput(btnL, false, true);
9576 }
9577 bool DrunkcRbtn()
9578 {
9579 return getInput(btnR, false, true);
9580 }
9581 bool DrunkcPbtn()
9582 {
9583 return getInput(btnP, false, true);
9584 }
9585
9586 bool DrunkrUp()
9587 {
9588 return getInput(btnUp, true, true);
9589 }
9590 bool DrunkrDown()
9591 {
9592 return getInput(btnDown, true, true);
9593 }
9594 bool DrunkrLeft()
9595 {
9596 return getInput(btnLeft, true, true);
9597 }
9598 bool DrunkrRight()
9599 {
9600 return getInput(btnRight, true, true);
9601 }
9602 5376994 bool DrunkrAbtn()
9603 {
9604 5376994 return getInput(btnA, true, true);
9605 }
9606 5392656 bool DrunkrBbtn()
9607 {
9608 5392656 return getInput(btnB, true, true);
9609 }
9610 71669 bool DrunkrEx1btn()
9611 {
9612 71669 return getInput(btnEx1, true, true);
9613 }
9614 71662 bool DrunkrEx2btn()
9615 {
9616 71662 return getInput(btnEx2, true, true);
9617 }
9618 bool DrunkrEx3btn()
9619 {
9620 return getInput(btnEx3, true, true);
9621 }
9622 bool DrunkrEx4btn()
9623 {
9624 return getInput(btnEx4, true, true);
9625 }
9626 bool DrunkrSbtn()
9627 {
9628 return getInput(btnS, true, true);
9629 }
9630 bool DrunkrMbtn()
9631 {
9632 return getInput(btnM, true, true);
9633 }
9634 6047645 bool DrunkrLbtn()
9635 {
9636 6047645 return getInput(btnL, true, true);
9637 }
9638 6044263 bool DrunkrRbtn()
9639 {
9640 6044263 return getInput(btnR, true, true);
9641 }
9642 bool DrunkrPbtn()
9643 {
9644 return getInput(btnP, true, true);
9645 }
9646
9647 8494 void eat_buttons()
9648 {
9649 8494 getInput(btnA, true, false, true);
9650 8494 getInput(btnB, true, false, true);
9651 8494 getInput(btnS, true, false, true);
9652 8494 getInput(btnM, true, false, true);
9653 8494 getInput(btnL, true, false, true);
9654 8494 getInput(btnR, true, false, true);
9655 8494 getInput(btnP, true, false, true);
9656 8494 getInput(btnEx1, true, false, true);
9657 8494 getInput(btnEx2, true, false, true);
9658 8494 getInput(btnEx3, true, false, true);
9659 8494 getInput(btnEx4, true, false, true);
9660 8494 }
9661
9662 // Is true for the _first frame_ of a key press.
9663 // But! it is possible that a script manually sets the value of KeyPress,
9664 // in which case it will be restored to the "true" value based on `key_current_frame`
9665 // and `key_previous_frame` on the next frame.
9666 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9667 {
9668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9670 {
9671 case KEY_F7:
9672 case KEY_F8:
9673 case KEY_F9:
9674 return KeyPress[k];
9675
9676 default:
9677
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9678 }
9679 14 }
9680
9681 // Is true for _every frame_ a key is held down.
9682 // But! it is possible that a script manually sets the value of KeyInput,
9683 // in which case it will be restored to the "true" value based on `key_current_frame`
9684 // on the next frame.
9685 bool zc_getkey(int32_t k, bool ignoreDisable)
9686 {
9687 if(ignoreDisable) return KeyInput[k];
9688 switch(k)
9689 {
9690 case KEY_F7:
9691 case KEY_F8:
9692 case KEY_F9:
9693 return KeyInput[k];
9694
9695 default:
9696 return KeyInput[k] && !disabledKeys[k];
9697 }
9698 }
9699
9700 // Reads (and then clears) the current frame key state directly.
9701 // Scripts can also modify `key_current_frame`.
9702 202 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9703 {
9704
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 200 times.
202 if(zc_getrawkey(k, ignoreDisable))
9705 {
9706 2 _key[k]=key[k]=key_current_frame[k]=0;
9707 2 return true;
9708 }
9709 200 _key[k]=key[k]=key_current_frame[k]=0;
9710 200 return false;
9711 202 }
9712
9713 // Reads the current frame key state directly.
9714 // Scripts can also modify `key_current_frame`.
9715 55362122 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9716 {
9717
2/2
✓ Branch 0 taken 47225262 times.
✓ Branch 1 taken 8136860 times.
55362122 if(ignoreDisable) return key_current_frame[k];
9718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8136860 times.
8136860 switch(k)
9719 {
9720 case KEY_F7:
9721 case KEY_F8:
9722 case KEY_F9:
9723 return key_current_frame[k];
9724
9725 default:
9726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8136860 times.
8136860 return key_current_frame[k] && !disabledKeys[k];
9727 }
9728 55362122 }
9729
9730 // Only used for a handful of keys, like tilde and Function keys.
9731 // This state is never read within the game.
9732 // It exists so that all keyboard input still functions during replay,
9733 // without inadvertently doing things like toggling throttling if the player
9734 // presses ~
9735 16273763 bool zc_get_system_key(int32_t k)
9736 {
9737 16273763 return key_system[k];
9738 }
9739
9740 // True for the _first_ frame of a key press.
9741 73231488 bool zc_read_system_key(int32_t k)
9742 {
9743 73231488 return key_system_press[k];
9744 }
9745
9746 1033377664 bool is_system_key(int32_t k)
9747 {
9748
2/2
✓ Branch 0 taken 960146176 times.
✓ Branch 1 taken 73231488 times.
1033377664 switch (k)
9749 {
9750 case KEY_BACKQUOTE:
9751 case KEY_CLOSEBRACE:
9752 case KEY_END:
9753 case KEY_HOME:
9754 case KEY_OPENBRACE:
9755 case KEY_PGDN:
9756 case KEY_PGUP:
9757 case KEY_TAB:
9758 case KEY_TILDE:
9759 73231488 return true;
9760 }
9761 960146176 return is_Fkey(k);
9762 1033377664 }
9763
9764 8136832 void update_system_keys()
9765 {
9766
2/2
✓ Branch 0 taken 1033377664 times.
✓ Branch 1 taken 8136832 times.
1041514496 for (int32_t q = 0; q < 127; ++q)
9767 {
9768
2/2
✓ Branch 0 taken 170873472 times.
✓ Branch 1 taken 862504192 times.
1033377664 if (!is_system_key(q))
9769 862504192 continue;
9770
9771 170873472 key_system[q] = key[q];
9772
1/2
✓ Branch 0 taken 170873472 times.
✗ Branch 1 not taken.
170873472 key_system_press[q] = key_system[q] && !key_system_previous[q];
9773 170873472 key_system_previous[q] = key_system[q];
9774 170873472 }
9775 8136832 }
9776
9777 9241589 void update_keys()
9778 {
9779
2/2
✓ Branch 0 taken 1173681803 times.
✓ Branch 1 taken 9241589 times.
1182923392 for (int32_t q = 0; q < 127; ++q)
9780 {
9781 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9782
1/2
✓ Branch 0 taken 1173681803 times.
✗ Branch 1 not taken.
1173681803 if (!replay_is_replaying())
9783 key_current_frame[q] = key[q];
9784
9785
2/2
✓ Branch 0 taken 1165013539 times.
✓ Branch 1 taken 8668264 times.
1173681803 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9786 1173681803 KeyInput[q] = key_current_frame[q];
9787 1173681803 key_previous_frame[q] = key_current_frame[q];
9788 1173681803 }
9789 9241589 }
9790
9791 bool zc_disablekey(int32_t k, bool val)
9792 {
9793 switch(k)
9794 {
9795 case KEY_F7:
9796 case KEY_F8:
9797 case KEY_F9:
9798 return false;
9799
9800 default:
9801 disabledKeys[k] = val;
9802 return true;
9803 }
9804 }
9805
9806 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9807 {
9808 timer=timer;
9809 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9810 }
9811